This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nil? can be used on any Ruby object. It returns true only if the object is nil. | |
nil.nil? # => true | |
[].nil? # => false | |
{}.nil? # => false | |
"".nil? # => false | |
" ".nil? # => false | |
true.nil? # => false | |
# empty? can be used on some Ruby objects including Arrays, Hashes and Strings. It returns true only if the object's length is zero. | |
nil.empty? # NoMethodError: undefined method `empty?' for nil:NilClass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install dkms build-essential linux-headers-generic | |
# On virtual machine’s menu bar on top, click on Device/Install Guest Additions. This will launch a unix script runing on the Ubuntu terminal. | |
sudo reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install libatlas-base-dev | |
sudo apt-get install gfortran | |
sudo apt-get install python-matplotlib | |
sudo pip install numpy | |
sudo pip install pandas | |
sudo pip install scipy | |
sudo pip install patsy | |
sudo pip install matplotlib | |
sudo pip install jinja2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [('SFO', 'HKO'), ('YYZ', 'SFO'), ('YUL', 'YYZ'), ('HKO', 'ORD')] | |
# extract nodes | |
nodes = list(set([val for s in data for val in s])) | |
# build a graph | |
graph = {} | |
for n in nodes: | |
graph[n] = [] | |
paths = [path for path in data if n in path] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installing RVM and Ruby: | |
sudo apt-get install curl | |
\curl -L https://get.rvm.io | bash -s stable --ruby | |
echo 'source $HOME/.rvm/scripts/rvm' >> ~/.bashrc | |
source ~/.bashrc | |
rvm requirements | |
rvm install 1.8.7-p371 | |
rvm install 1.9.3-p125 | |
rvm --default use ruby-1.9.3-p125 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List all processes dynamically, q to close top, k to kill a process | |
top | |
# Displays processes in tree format | |
pstree | |
# Display all running processes owned by the current user | |
# ps aux | |
# Find a process |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
udo apt-get install tcptrack | |
sudo tcptrack -i eth0 -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get install python-pip | |
sudo apt-get install python-setuptools | |
sudo apt-get install python-dev | |
sudo apt-get install build-essential | |
sudo pip install virtualenv | |
sudo pip install virtualenvwrapper | |
sudo echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc | |
sudo echo 'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls *.txt | wc -l | tee /dev/tty count.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Actions are method invocations from View to View Controller. | |
// Outlets are method invocations from View Controller to view. | |
// Initial Setup for ViewControllers | |
// ViewDidLoad - Called when you create the class and load from xib. Great for initial setup and one-time-only work. | |
// ViewWillAppear - Called right before your view appears, good for hiding/showing fields or any operations that you want to happen every time before the view is visible. Because you might be going back and forth between views, this will be called every time your view is about to appear on the screen. | |
// ViewDidAppear - Called after the view appears - great place to start an animations or the loading of external data from an API. | |
// ViewWill/DidDisappear - Same idea as WillAppear. | |
// ViewDidUnload/ViewDidDispose - In Objective C, this is where you do your clean-up and release of stuff, but this is handled automatically so not much you really need to do here. |
NewerOlder