Skip to content

Instantly share code, notes, and snippets.

View ahadshafiq's full-sized avatar

Ahad Shafiq ahadshafiq

View GitHub Profile
@ahadshafiq
ahadshafiq / Stuck bundle install
Created April 26, 2013 03:21
$ bundle install Fetching gem metadata from http://rubygems.org/........ Fetching gem metadata from http://rubygems.org/..
If bundle install gets stuck at
$ bundle install
Fetching gem metadata from http://rubygems.org/........
Fetching gem metadata from http://rubygems.org/..
then delete the contents of Gemfile.lock
Btw, in vim thats:
If you're in the first line of the file, use dG
If you're anywhere in the file, use :1,$d
@ahadshafiq
ahadshafiq / PATH, bash
Created April 19, 2013 23:23
Random notes on PATH, bash
echo $PATH
PATH tells Bash where to look to find the executables like "ls" -
usually , they'll be somwehre like /usr/bin
You need to add those directories to your PATH to make them work.
path needs to list all the locations where binary files are found
eg: bin;usr/bin;/usr/local/bin. If you want to change your shell
then instead of PATH=/usr/bin/ksh you need
Code:
SHELL=/usr/bin/ksh
@ahadshafiq
ahadshafiq / Performance
Created April 13, 2013 16:41
Some notes on Performance
--------------------------------------------------
Server Stack
--------------------------------------------------
As with other *nix applications, you can control nginx through the use
of signals. To use signals, you’ll need the process ID.
nginx is architected as a single master
process with any number of worker processes.
You can stop the master process with the
@ahadshafiq
ahadshafiq / Ruby SSL Error
Created April 11, 2013 23:07
Fixing an SSL error that came up during Janus curl. openssl::ssl::sslerror: ssl_connect returned=1 errno=0 state=sslv3 read server certificate b: certificate verify failed
rvm -v
rvm get head
rvm -v
rvm osx-ssl-certs status all
The above will show if certificates are outdated:
Certificates for /opt/sm/pkg/versions/openssl/1.0.1c/ssl/cert.pem: Old.
rvm osx-ssl-certs update all
The above will update the certificates:
@ahadshafiq
ahadshafiq / Masterclass: Git
Created April 11, 2013 08:41
Masterclass: Git
http://mislav.uniqpath.com/2010/07/git-tips/
@ahadshafiq
ahadshafiq / Show Controller#Action in browser
Created April 10, 2013 09:08
Rails debugging: params
put <%= params.inspect %> in application.html.erb
@ahadshafiq
ahadshafiq / rake db:what
Created April 8, 2013 15:28
Active Record database commands
db:create creates the database for the current env
db:create:all creates the databases for all envs
db:drop drops the database for the current env
db:drop:all drops the databases for all envs
db:migrate runs migrations for the current env that have not run yet
db:migrate:up runs one specific migration
db:migrate:down rolls back one specific migration
db:migrate:status shows current migration status
db:migrate:rollback rolls back the last migration
db:forward advances the current schema version to the next one
@ahadshafiq
ahadshafiq / Git Workflow
Created April 8, 2013 13:15
Git workflow to follow
http://nvie.com/posts/a-successful-git-branching-model/
Master
Develop
Feature1
Feature2
Feature3
Get original source updates to master. By git pull origin originalmaster.
Check where git remote is for originamaster. git remote -v
@ahadshafiq
ahadshafiq / Useful sh functions
Created April 3, 2013 15:22
Useful bashrc/.bash_profile/bash.bashrc functions
ListAllCommands | grep searchstr
function ListAllCommands
{
COMMANDS=`echo -n $PATH | xargs -d : -I {} find {} -maxdepth 1 \
-executable -type f -printf '%P\n'`
ALIASES=`alias | cut -d '=' -f 1`
echo "$COMMANDS"$'\n'"$ALIASES" | sort -u
}
Instead of
rails server
do:
rails s -d
then to kill it, find which process is using the port:
lsof -i :3000
finally, kill the process:
kill -9 $(lsof -i :3000 -t)