Skip to main content

Posts

Showing posts with the label howto

Install bcrypt on Mac OSX

 Basically One can do it wih homebrew. About the App App name : bcrypt App description : Cross platform file encryption utility using blowfish App website :  http://bcrypt.sourceforge.net Install the homebrew package manager Open  Terminal  and press  enter/return  key. Copy and paste the following command in Terminal app: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" and press  enter/return  key. Wait for the command to finish. If you are prompted to enter a password, please type your Mac user's login password and press ENTER. Mind you, as you type your password, it won't be visible on your Terminal (for security reasons), but rest assured it will work. Now, copy/paste and run this command to make  brew  command available inside the Terminal:  echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile Install the bcrypt lib Copy and paste the following command: brew inst...

Promise -fication of JS calls.

Found a new pattern to use recently that is called Promise. I really like the way ES6/7 brings new thinking patterns into life nowdays. Here is Promise used instead of old pattern. It was to give JS method a callback function. This splitting code and making a lot of possibilities for error to come out in this place. One would write old times according to MDN : function greeting ( name ) { alert ( 'Hello ' + name ); } function processUserInput ( callback ) { var name = prompt ( 'Please enter your name.' ); callback ( name ); } processUserInput ( greeting ); And now it is made with Promise pattern like so: let promise = new Promise (( resolve , reject ) => { resolve ( prompt ( 'Please enter your name.' )); }); promise . then (( name ) => { alert ( 'Hello ' + name ); }); In general and briefly this now helps to avoid 'callback hell' with functions passed as arguments and write as...

Install Docker under Ubuntu 14.04 (Trusty)

Docker supports Ubuntu versions: Ubuntu Vivid 15.04 (64-bit) Ubuntu Trusty 14.04 (LTS) (64-bit) Ubuntu Precise 12.04 (LTS) (64-bit) Ubuntu Raring 13.04 and Saucy 13.10 (64 bit)  For both Vivid and Trusty you need nothing. It will work out of the box. Others will require some modifications. (Updating of some things, like kernel or installing with wget on 13.04) 1. To install docker from a repository do so: sudo apt - get update sudo apt - get install docker . io sudo ln - sf / usr / bin / docker . io / usr / local / bin / docker sudo sed - i '$acomplete -F _docker docker' / etc / bash_completion . d / docker . io 2. Now run it with: sudo apt - get install lxc - docker 3. Make it run on system boot: sudo update - rc . d docker . io defaults 4. Ready to go! Run container with an Ubuntu: sudo docker run - i - t ubuntu / bin / bash To disconnect, or detach, from the shell without exiting use the escape sequence Ctrl-p + Ctrl-q . 

Remi and EPEL repositories in CentOS

There are 2 common repositories that come nowdays for centos. They contain tasty things, while they are absent in official repositories. CentOS 5: wget http : //dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm wget http : //rpms.famillecollet.com/enterprise/remi-release-5.rpm sudo rpm - Uvh remi - release - 5 * . rpm epel - release - 5 * . rpm CentOS 6: wget http : //dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm wget http : //rpms.famillecollet.com/enterprise/remi-release-6.rpm sudo rpm - Uvh remi - release - 6 * . rpm epel - release - 6 * . rpm You can check you are successful like so: ls - 1 / etc / yum . repos . d / epel * / etc / yum . repos . d / remi . repo / etc / yum . repos . d / epel . repo / etc / yum . repos . d / epel - testing . repo / etc / yum . repos . d / remi . repo Now you are only left to activate Remi repository: sudo vi / etc / yum . repos . d / remi . repo In [remi] section we need to change enable...

Python sort() patterns

Python has a lot of sorting patterns. Let's make a short a list. 1. Sorting list by it's element. Simple case. Should simply do: > > > exmpl_list = [ 'a' , 'c' , 'B' , 'd' ] > > > exmpl_list . sort ( ) [ 'a' , 'B' , 'c' , 'd' ] However this example does not take locale into account and works only for ASCII characters. 2. Sorting list of sub elements. exmpl_list = [ { 'name' : 'Homer' , 'age' : 39 } , { 'name' : 'Bart' , 'age' : 10 } ] # Sorting by 'name' newlist = sorted ( exmpl_list , key = lambda k : k [ 'name' ] ) # Better way to use itemgetter(): from operator import itemgetter newlist = sorted ( exmpl_list , key = itemgetter ( 'name' ) ) Note that it is equivalent to: exmpl_list . sort ( key = lambda k : k [ 'name' ] ) # OR: exmpl_list . sort ( key = ite...