Posts

Redis: The Basics

Image
What is Redis ? - Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker - Remote Dictionary Server Installation For Mac OS X: 1. Install XCode Developer Tools 2. Download the stable release on Redis official site: http://redis.io/download 3. Run the ff. command: wget http://download.redis.io/releases/redis-3.2.0.tar.gz tar xzf redis-3.2.0.tar.gz cd redis-3.2.0 # install and run globally (/usr/local/bin) make install redis-server # install and run locally make cd src && ./redis-server # install on another location make install /opt/local/bin For Ubuntu: 1. Run the ff. command: sudo apt-get install redis-server # run redis-server Data Types List: - collection of string elements, sorted according to the order of insertion. ex. 8, 9, 1, 2, 3 - implemented using a linked list, not using an array - insertion of new elements to head or tail is at constant time regardless of the length of the list ...

PHPUnit: Basics of Unit Testing

Image
What is Unit Testing ? Unit Testing is a software testing method by which individual units of code are tested to determine if they are fit to use. Benefits of Unit Testing - find problems early - facilitates changes - simplifies integration - documentation - design interface What is PHPUnit? - xUnit-style library by Sebastian Bergmann - Installable via Composer, PEAR and Phar - well integrated and well documented reference: http://phpunit.de/manual/current/en/index.html Installation (globally via Phar) wget https://phar.phpunit.de/phpunit.phar chmod +x phpunit.phar mv phpunit.phar /usr/bin/phpunit source: http://phpunit.de/manual/current/en/installation.html Installation (as vendor via Composer) Create a composer.json file in the root directory then add the ff.: { "require-dev" : { "phpunit/phpunit" : "4.8.0" }, "autoload" : { "psr-4" : { "Project\\" : "app...

Install Symfony on Vagrant Environment

Image
Vagrant is a tool for building and managing virtual machine environments. Assuming you have already installed and  vagrant up your virtual environment. Execute the following instructions on your terminal console. Download symfony installer sudo curl -LsS https://symfony.com/installer -o /usr/local/bin/symfony sudo chmod a+x /usr/local/bin/symfony Create project directory symfony new my_project Then, you can: * Change your current directory to /vagrant/my_project * Configure your application in app/config/parameters.yml file. * Run your application: 1. Execute the php bin/console server:run command. 2. Browse to the http://localhost:8000 URL. * Read the documentation at http://symfony.com/doc Running #1, should produce result similar to this: php bin/console server:run [OK] Server running on http://127.0.0.1:8000 // Quit the server with CONTROL-C. If you have private network map set in Vagrantfile then do not use server:run as it only listens to http...

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