Skip to content

Instantly share code, notes, and snippets.

View pythonicrubyist's full-sized avatar

Ramtin Vaziri pythonicrubyist

View GitHub Profile
@pythonicrubyist
pythonicrubyist / nil_empty_blank_present_ffdierence_in_ruby
Last active February 21, 2024 17:38
Difference between nil?, empty?, blank? and present? in Ruby and Ruby on Rasils.
# 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
@pythonicrubyist
pythonicrubyist / gist:7683471
Created November 27, 2013 21:23
Enabling Full-Screen Mode in Ubuntu on Oracle VirtualBox
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
@pythonicrubyist
pythonicrubyist / setting_up_python_data_analysis_environment_on_ubuntu_linux
Last active March 28, 2021 03:11
Setting up a Python Data Analysis Environment on Ubuntu LTS 12.04 or Linux Mint 13.
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
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]
@pythonicrubyist
pythonicrubyist / convert_ubuntu_mint_to_ruby_dev_env
Last active November 29, 2016 10:59
Converting Ubuntu 12.04 LTS or LInux Mint 13 into a Ruby Developer’s Environment
# 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
@pythonicrubyist
pythonicrubyist / linus_process_management
Created December 12, 2013 17:37
Linux Command for Process Management and Network Monitoring
# 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
@pythonicrubyist
pythonicrubyist / gist:7683298
Created November 27, 2013 21:14
TCP Network Traffic Monitor in Linux
udo apt-get install tcptrack
sudo tcptrack -i eth0 -f
@pythonicrubyist
pythonicrubyist / convert_ubuntu_mint_to_python_dev_env
Last active December 29, 2015 00:59
Converting Ubuntu 12.04 LTS or LInux Mint 13 into a Python Developer’s Environment
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
@pythonicrubyist
pythonicrubyist / handy_linux_commands
Created October 30, 2013 16:30
Handy Linux Commands
ls *.txt | wc -l | tee /dev/tty count.txt
@pythonicrubyist
pythonicrubyist / iOS_dev_swift_notes
Last active August 29, 2015 14:16
IOS developments with Swift
// 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.