Install any version of Node.js on CentOS 6 using NVM

I’m not sure if the ‘yum’ install works on other CentOS or not. But I come across the problem that I get some problems with upgrading NodeJS from v0.10 to v5.4.0 on CentOS. I don’t know what I should do so I started clean, and found that install nvm is super easy then install NodeJS itself. (And the perk is that you can have multiple versions of Node.js that you want!)

I don’t know about the perf though. Feel free to share if you do!

How to do:

Follow the instruction here: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-a-centos-7-server

(Section “Install Node Using the Node Version Manager”)

For short:

curl https://raw.githubusercontent.com/creationix/nvm/v0.13.1/install.sh | bash
source ~/.bash_profile
nvm list-remote
nvm install v5.4.0 # or whichever version you'd like
nvm list # must have v5.4.0 show in the list
nvm use v5.4.0 # use it
nvm alias default v5.4.0 # set default node
node --version # there should show v5.4.0

Voila!

Install Virtualenv with Wrapper for OSX and zsh

Get necessary lib

sudo easy_install pip #probably don't need to sudo
sudo pip install virtualenv #probably don't need to sudo
sudo pip install virtualenvwrapper #probably don't need to sudo

Append this to ~/.zshrc (the file is hidden)

# set where virutal environments will live
export WORKON_HOME=$HOME/.virtualenvs
# ensure all new environments are isolated from the site-packages directory
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
# use the same directory for virtualenvs as virtualenvwrapper
export PIP_VIRTUALENV_BASE=$WORKON_HOME
# makes pip detect an active virtualenv and install to it
export PIP_RESPECT_VIRTUALENV=true
if [[ -r /usr/local/bin/virtualenvwrapper.sh ]]; then
    source /usr/local/bin/virtualenvwrapper.sh
else
    echo "WARNING: Can't find virtualenvwrapper.sh"
fi

You might need to restart your zsh.

Creating env

mkvirtualenv testenv

it will access the env automatically

Feel free to ‘pip’ anything now

pip install rq

more at: http://mkelsey.com/2013/04/30/how-i-setup-virtualenv-and-virtualenvwrapper-on-my-mac/

Compile .less file in Sublime Text for nvm

This works on Sublime Text 3 only.

1. Install sublime-less2css package.
(Package Control: Install Pagekage -> sublime-less2css)

2. Make sure you have node & npm. Then install the following package globally

npm install less -gd
npm install -g less-plugin-clean-css
npm install -g less-plugin-autoprefix

3. If it doesn’t work (less2css error: `lessc` is not available):
– Go to Preferences > Package Settings > Less2Css > Settings – Default and copy the default settings
– Paste default settings to Preferences > Package Settings > Less2Css > Settings – User and edit the lesscCommand property to your lessc path:

"lesscCommand": "/Users/vee/.nvm/v4.2.1/bin/lessc",

– Save and try again

4. If you get env: node error (env: node: No such file or directory):
Find your node path:

which node

Create symlink your node path to /usr/bin/node
sudo ln -s /Users/vee/.nvm/v4.2.1/bin/node /usr/bin/node

^ The above solution isn’t working anymore in OXS El Capitan (source). I solved by installing a sublime package named Fix Mac Path. Restart and it should work!

5. (Bonus) If you’re using nvm. Don’t forget to set the default nvm:

nvm alias default 4.2.1

Source:
http://stackoverflow.com/questions/20061529/sublime-text-coffeescript-build-system-env-node-no-such-file-or-directory
http://stackoverflow.com/questions/24585261/nvm-keeps-forgetting-node-in-new-terminal-session
https://github.com/timdouglas/sublime-less2css

How to get/create “Release Key Hash” for Android’s Facebook API

After digitally signed and created an apk, remember your 1) Key store path, 2) Key alias, and 3) Key password. Then enter this on the command:

keytool -exportcert -alias KEY_ALIAS_HERE -keystore KEY_STORE_PATH_HERE | openssl sha1 -binary | openssl base64

For example,
Key alias: DistributionKeyStoreAlias
Key store path: /Users/vee/androidkeystore.jks

keytool -exportcert -alias DistributionKeyStoreAlias -keystore /Users/vee/androidkeystore.jks | openssl sha1 -binary | openssl base64

And copy the code and enter it in Facebook developer’s setting page > Android section > Release Key Hash.

Change ‘new line’ button to ‘Enter/Next/Done’ on Android

Key is:

        android:imeOptions="actionDone"
        android:singleLine="true"
    <EditText
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/etStatus"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:background="#FFFFFFFF"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="20dp"
        android:editable="true"
        android:enabled="true"
        android:hint="Enter message to broadcast"
        android:imeOptions="actionDone"
        android:singleLine="true"
        android:padding="10dp"
        android:lines="1"
        android:longClickable="false" />