Thursday, October 30, 2014

Create OS X Yosemite USB drive Installer

1. Download OS X Yosemite from App Store. After download, make sure "Install OS X Yosemite.app" is in the /Applications directory.

2. Insert USB (at least 8GB). No need to clean or format. Installation will format this drive. Take note of the name of the drive via Finder (under devices) or type mount from Terminal and take note of the /Volumes/name_of_usb_drive

3. Open Terminal via Applications->Terminal

4. Type the following from the command line. Replace [name_of_usb_drive] with the name of the drive from #2.

sudo /Applications/Install\ OS\ X\ Yosemite.app/Contents/Resources/createinstallmedia --volume /Volumes/[name_of_usb_drive] --applicationpath /Applications/Install\ OS\ X\ Yosemite.app --nointeraction
 
5. You will see something like the following, follow instructions and/or let it finish.

"Erasing Disk: 0%... 10%... 20%... 30%...100%... 
Copying installer files to disk... 
Copy complete. 
Making disk bootable... 
Copying boot files... 
Copy complete. 
Done."
 
6. Reboot. Press Option key during boot and choose Install OS X Yosemite drive upon boot.

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