Wednesday, September 10, 2014

Install Apache Cassandra on OS X


 # Requirement
Java 7 

# Download Apache Cassandra 2.0.10 from http://cassandra.apache.org/download/
wget http://www.apache.org/dyn/closer.cgi?path=/cassandra/2.0.10/apache-cassandra-2.0.10-bin.tar.gz

# Extract to e.g /usr/local; create symlink
cd /usr/local
tar -xzvf apache-cassandra-2.0.10-bin.tar.gz
ln -s apache-cassandra-2.0.10-bin.tar.gz cassandra

# Create Cassandra directories
sudo mkdir /var/lib/cassandra
sudo mkdir /var/lib/cassandra/data
sudo mkdir /var/lib/cassandra/commitlog
sudo mkdir /var/lib/cassandra/saved_caches
sudo mkdir /var/log/cassandra

# Run Cassandra
cd /usr/local/cassandra
sudo bin/cassandra -f




# Test connection; Open new terminal window
cd /usr/local/cassandra
bin/cqlsh


Saturday, September 6, 2014

Setup Sublime 3 for Web Development

# Download & Install Sublime 3
http://www.sublimetext.com/3

# Install Package Control 
# Copy to clipboard the installation script from https://sublime.wbond.net/installation

# Open Sublime 3 and open console
CTRL + ` (or View->Show Console)

# Paste the Package Control script into the console and press Enter

# Install Packages
# Open Sublime's Command Palette
CTRL + SHIFT + p (or Tools->Command Palette)

#  Select Install Package
Package Control : Install Package

# Must Haves
 SublimeCodeIntel
 SublimeLinter

# For Web Dev
 SublimeLinter-jshint SublimeLinter-json
 SublimeLinter-csslint
 SideBarEnhancements
 VCS Gutter

# For PHP
 SublimeLinter-php
 phpdoc
 phpcs
 XDebug Client

# Non-free
SFTP

Wednesday, September 3, 2014

Secure your iOS iCloud Account with 2 Factor Authentication

# Go to My Apple ID page via https://appleid.apple.com
#

# Select Manage your Apple ID
# Sign-in to you Manage your Apple ID
# Select Password and Security
# Answer your Security Questions and press Continue
# Manage Security Settings via clicking Get Started.. link
# Two-step verification page will be display then click Continue
# Click Get Started button
# Add your mobile phone to receive SMS and follow instructions
# Enter the code received from your Phone and click Verify button
# Print or print down Recovery key and keep it safe
# Enable two-step verification by checking "I understand the conditions above" and clicking the "Enable two-step Verification" button



Install PHP Profiler XHProf on Debian

# Install Prerequisites
apt-get install php5-dev graphviz php-pear

# Install XHProf
pecl config-set preferred_state beta
pecl install xhprof

# Create XHProf output directory
mkdir /tmp/xhprof
chown www-data:www-data /tmp/xhprof

# Include XHProf Alias in /etc/apache2/sites-available/default

Alias /xhprof_html /usr/share/php/xhprof_html/

   Options FollowSymLinks
   AllowOverride Alll
   Order allow, deny
   Allow from all


# Create PHP page for initializing XHProf e.g. vi /var/www/xhprof_header.php

// Init XHPROF
if (extension_loaded('xhprof')) {
    xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
    $XHPROF_ROOT = '/usr/share/php';
    include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
    include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
}

$i = 0;
while ($i < 10000) {
    $i++;
}
?>
 
# Create PHP page for de-initializing XHProf e.g. vi /var/www/xhprof_footer.php
// De-Init XHPROF, generate report and link
if (extension_loaded('xhprof')) {
    $data = xhprof_disable();
    $xhprof_runs = new XHProfRuns_Default();
    $run_id = $xhprof_runs->save_run($data, "xhprof");
    $profiler_url = sprintf('http:///xhprof_html/index.php?run=%s', $run_id);
    echo 'Profiler output';
}
?> 

# Configure XHProf via /etc/php5/apache2/php.ini
# Prepend/Append XHProf initializer/deinitializer page

[xhprof]
extension=xhprof.so
xhprof.output_dir="/tmp/xhprof"

auto_prepend_file=/var/www/xhprof_header.php
auto_append_file=/var/www/xhprof_footer.php


# Restart Apache2
service apache2 restart