[ npm ] install global permission error

problem

$ npm install -g bower
npm WARN deprecated bower@1.8.2: ...psst! Your project can stop working at any moment because its dependencies can change. Prevent this by migrating to Yarn: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
npm ERR! tar.unpack untar error /home/pong/.npm/bower/1.8.2/package.tgz
npm ERR! Linux 4.10.0-19-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "bower"
npm ERR! node v4.8.4
npm ERR! npm v2.15.11
npm ERR! path /usr/lib/node_modules/bower
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/bower'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/bower']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/lib/node_modules/bower',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/lib/node_modules/bower',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR! '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR! 'FSReqWrap.oncomplete (fs.js:82:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR! /home/pong/npm-debug.log

recommended ​​​​​​Option 2: Change npm’s default directory to another directory

$ mkdir ~/.npm-global
$ npm config set prefix '~/.npm-global'

put this in ~/.profile

export PATH=~/.npm-global/bin:$PATH

then update your system variables

source ~/.profile

ref : https://docs.npmjs.com/getting-started/fixing-npm-permissions

Advertisements

[ gem ] bundle install mysql; checking for mysql_query() in -lmysqlclient… no

problem

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory:/home/pong/.rvm/gems/ruby-2.1.2@toaster/gems/mysql2-0.3.18/ext/mysql2/home/pong/.rvm/rubies/ruby-2.1.2/bin/ruby -r ./siteconf20171017-2320-19gfum4.rbextconf.rbchecking for ruby/thread.h... yeschecking for rb_thread_call_without_gvl() in ruby/thread.h... yeschecking for rb_thread_blocking_region()... yeschecking for rb_wait_for_single_fd()... yeschecking for rb_hash_dup()... yeschecking for rb_intern3()... yeschecking for mysql_query() in -lmysqlclient... nochecking for main() in -lm... yeschecking for mysql_query() in -lmysqlclient... nochecking for main() in -lz... yeschecking for mysql_query() in -lmysqlclient... nochecking for main() in -lsocket... nochecking for mysql_query() in -lmysqlclient... nochecking for main() in -lnsl... yeschecking for mysql_query() in -lmysqlclient... nochecking for main() in -lmygcc... nochecking for mysql_query() in -lmysqlclient... no*** extconf.rb failed ***Could not create Makefile due to some reason, probably lack of necessarylibraries and/or headers.  Check the mkmf.log file for more details.  You mayneed configuration options.
Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/home/pong/.rvm/rubies/ruby-2.1.2/bin/ruby --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysql-config --without-mysql-config --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysqlclientlib --without-mysqlclientlib --with-mlib --without-mlib --with-mysqlclientlib --without-mysqlclientlib --with-zlib --without-zlib --with-mysqlclientlib --without-mysqlclientlib --with-socketlib --without-socketlib --with-mysqlclientlib --without-mysqlclientlib --with-nsllib --without-nsllib --with-mysqlclientlib --without-mysqlclientlib --with-mygcclib --without-mygcclib --with-mysqlclientlib --without-mysqlclientlib
To see why this extension failed to compile, please check the mkmf.log which canbe found here:
/home/pong/.rvm/gems/ruby-2.1.2@toaster/extensions/x86_64-linux/2.1.0/mysql2-0.3.18/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in/home/pong/.rvm/gems/ruby-2.1.2@toaster/gems/mysql2-0.3.18 for inspection.Results logged to/home/pong/.rvm/gems/ruby-2.1.2@toaster/extensions/x86_64-linux/2.1.0/mysql2-0.3.18/gem_make.out
An error occurred while installing mysql2 (0.3.18), and Bundler cannotcontinue.Make sure that `gem install mysql2 -v '0.3.18'` succeeds before bundling.
In Gemfile:  mysql2

solution

sudo apt-get install libmysqlclient-dev

ref: https://stackoverflow.com/questions/5795309/gem-install-mysql-fail

[ ubuntu 16.04 ] share clipboard

  • Install Guest Additions CD image
  • Settings > General > advanced tab >
    Shared Clipboard : bidirectional
    Drag and drop : bidirectional

If it does not work, try installing virtualbox-guest-dkms.

sudo apt-get install virtualbox-guest-dkms

Then reboot

ref : https://askubuntu.com/questions/533071/virtualbox-4-12-shared-clipboard-not-working-in-ubuntu14-04,

https://dsin.blogspot.com/2015/11/virtualbox-share-clipboard.html

[ selenium ] 101

GET page

driver.get(baseUrl + "/90719/edit");

Find webElement by anchor/by name

WebElement element = driver.findElement(By.linkText("CREATE A POST"));
WebElement element = driver.findElement(By.name("targetSeoKeyphrase"));
driver.findElement(By.cssSelector("button.btn.btn-default"));
driver.findElement(By.xpath("//button[@action='publishNow']"));

ref : https://loadfocus.com/blog/2013/09/05/how-to-locate-web-elements-with-selenium-webdriver/

webElement action

webElement.click();
webElement.clear();
webElement.sendKeys("test simple article");
webElement.getText();

check from pageSource

driver.getPageSource().contains("Blog")

 

 

[ mixin ] rhythm : Margins and Padding

Using our 42px <h1> example from earlier we might do something like:

h1 {
  @include rhythm(3, 1, 0, 2, 42px);
}

Rhythm syntax

rhythm($lines, $font-size, $offset)

Which compiles to:

h1 {
  margin-top: 1.714285714em;    // 3 units or 24*3 = 72px
  padding-top: .571428571em;    // 1 unit or 24px
  padding-bottom: 0;            // 0 units 0px
  margin-bottom: 1.142857143em; // 2 units or 24*2 = 48px
}

Functions are similar but return values that are used within a css rule. Let’s say I just want to set all 4 margins on my <h1> with a combination of rhythm units and standard CSS notation.

h1 {
  margin: 0 auto rhythm(3, 42px);
}

Which compiles to

h1 {
  margin: 0 auto 1.714285714em;
}

ref : https://atendesigngroup.com/blog/vertical-rhythm-compass

[ mixin ] adjust-font-size-to : font-size and line-height

1)

html {
  font-size: 100%;
  line-height: 1.5em;
}

* 16px is the default font size for most browsers, so 100% = 16px.
* A relative line-height is always relative to the font-size of the current element,
so in this case the line-height is set to 1.5 em ( 1.5 * 16px = 24px).

2) The fun starts when you begin setting font sizes on other elements.
Let’s say we want to make our <h1>s 42px. We do so using the adjust-font-size-to mixin.

Example :

h1 {
  @include adjust-font-size-to(42px);
}

2.1) First it sets our font-size relative to our element’s container, which in most cases will be our $base-font-size. So we get something like:

font-size: 2.625em;   // 2.625*16px=42px

2.2) Vertical Rhythm also sets line-height to a factor of our baseline grid, larger than the font-size.
So in the case of our 42px font-size, it sets the line-height to 48px or 2 baseline units or technically speaking

line-height: 1.142857143em;  // 1.142857143 * 42px = 48pxish

 

3) so what happens when you want to go down in font size?
Let’s say 12px on some meta data.
What we learned above would result in a line height of 24px, which would be akwardly large.
Easy! If we want a line height of 16px so that every 3rd line of our meta data lines up with every 2nd baseline.
We just pass the desired number of rhythm units to the same mixin.

In this case:

.meta {
  @include adjust-font-size-to(12px, 2/3);
}

 

ref : https://atendesigngroup.com/blog/vertical-rhythm-compass