Posts

Showing posts from April, 2016

Python: Install ansible with pip

Note that ansible can only be run on a machine with Python 2.6 or 2.7 Install ansible package using pip module: sudo pip install ansible Install required packages: sudo pip install paramiko PyYAML Jinja2 httplib2 six To install the latest development version: sudo pip install git+git://github.com/ansible/ansible.git@devel

Python: Creating Virtual Environments and Managing Packages

Creating the Virtual Environment Using virtualenv virtualenv [env_name] source [env_name]/bin/activate Using pyvenv (includes pip in the default packages) pyvenv [env_name] source [env_name]/bin/activate Managing Packages Install the latest version of package: pip install [package_name] Alternatively, you can use python -m to install a package using pip module: python -m [module_name] install [package_name] Install a specific version of a package pip install [package_name]==[version] If you would like to install the flask package with a minimum version, this is how to execute it: pip install flask>=0.10.1 Install packages just for the current user: pip install --user [package_name] Upgrade a package to the latest version: pip install --upgrade [package_name] Remove package(s) from the virtual environment: pip uninstall [package1] [package2] ... [package] Display information about a particular package: pip show [package] Display all the packages installed in

Vagrant: Installing Vagrant

Download VirtualBox and Vagrant Create a directory for your virtual environment mkdir vagrant_env1 cd vagrant_env1 Install your preferred box (Ubuntu 12.04 LTS 64-bit for this example): vagrant init hashicorp/precise64 or vagrant init vagrant box add hashicorp/precise64 You may check this HashiCorp's Atlas box catalog for more type of boxes. By the way, a "box" is a base image of an operating system. This enables you to quickly clone a virtual machine rather than starting from scratch, which would be a slow and tedious process. Installing may take some time, but after that, you can re-use this box when you want to create another virtual environment. Now run vagrant up: vagrant up To enter the virtual machine, simply SSH: vagrant ssh

Python: Install pip on Mac OS X

Download get-pip.py Run the following command: sudo python get-pip.py Upgrading pip: pip install -U pip

Vim: Using Abbreviations

VIM abbreviations can save typing and/or improve typing accuracy. By using :ab or :abbreviate , you can define abbreviations in VIM editor or the .vimrc file. i.e. This command will automatically replace "cia" with "central intelligence agency" :ab cia central intelligence agency or :abbreviate cia central intelligence agency i.e. You can also shorten a line of code :ab ubb #! /usr/bin/bash The above code will replace ubb with #! /usr/bin/bash The following command will remove a specific abbreviation :una ubb or :unabbreviate ubb This command will remove all abbreviations defined :abc or :abclear

Bash: Caret Substitution

Sample command: echo "dev" && echo "my dev" Replace "dev" with "prod": ^dev^prod Previous command will now be this: echo "prod" && echo "my dev" To replace all occurences of "dev": ^dev^prod^:& Previous command will now be this: echo "prod" && echo "my prod"

Getting Started with Composer

Install Composer Run this command in the root directory of your project: php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php php -r "if (hash('SHA384', file_get_contents('composer-setup.php')) === '41e71d86b40f28e771d4bb662b997f79625196afcca95a5abf44391188c695c6c1456e16154c75a211d238cc3bc5cb47') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');" Alternatively, you may run this in your command line: curl -sS https://getcomposer.org/installer | php Create the JSON file for your packages Put a file named composer.json at the root of your project, containing your project dependencies: { "require": { "vendor/package": "1.3.2", "vendor/package2": "1.*", "vendor/