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

Monday, August 18, 2014

Setup Apache Tomcat 8 on OS X Mavericks

# Prerequisite - Java installed
# Download Tomcat from tomcat.apache.org e.g. apache-tomcat-8.0.9.tar.gz

# Proceed to target installation directory
cd /usr/local

# Extract
tar -xzvf apache-tomcat-8.0.9.tar.gz

# Symlink shortname
ln -s apache-tomcat-8.0.9.tar.gz tomcat8

# Setup environment
vi setenv.sh

# Include CATALINA_HOME and JRE_HOME

# Add user
vi /usr/local/tomcat8/conf/tomcat-users.xml

# Include all roles (no need to create roles in the tomcat-users.xml )


# Start Tomcat
./startup.sh

# Stop Tomcat
./shutdown.sh

Sunday, August 10, 2014

JAVA_HOME Command Tool for OS X

# List installed Java
$/usr/libexec/java_home -verbose

Matching Java Virtual Machines (3):
  1.8.0_05, x86_64:  "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home
  1.6.0_65-b14-466.1, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
  1.6.0_65-b14-466.1, i386: "Java SE 6"   /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home



# Get Current Java  Home
$/usr/libexec/java_home

/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home


# Get path to 1.6 (if installed)
$/usr/libexec/java_home v1.6

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home

Homebrew "brew doctor" Unexpected file Warnings / Errors

Error:

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
    /usr/local/lib/libmacfuse_i32.2.dylib
    /usr/local/lib/libmacfuse_i64.2.dylib
    /usr/local/lib/libosxfuse_i32.2.dylib
    /usr/local/lib/libosxfuse_i64.2.dylib

Warning: Unbrewed .la files were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .la files:
    /usr/local/lib/libosxfuse_i32.la
    /usr/local/lib/libosxfuse_i64.la

Warning: Unbrewed .pc files were found in /usr/local/lib/pkgconfig.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected .pc files:
    /usr/local/lib/pkgconfig/osxfuse.pc


Solution:
If with TrueCrypt installed, use this script to fix https://gist.github.com/trinitronx/5437061
If OSXFuse installed, remove and use Homebrew's version