πΊπ¦
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
# Rails 2 and Rails 3 console | |
function rc { | |
if [ -e "./config/environment.rb" ]; then | |
irb -Iconfig -renvironment | |
else | |
echo -e "\e[1;31m Error: \e[0mNo rails environment was founded! \n" | |
fi | |
} |
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
rvm use @global | |
gem i bundler | |
mkdir my_app && cd my_app | |
rvm --create --rvmrc @my_app | |
bundle init | |
echo "gem 'rails', :github => 'rails/rails'" >> Gemfile | |
bundle | |
bundle exec rails new . | |
bundle exec rails server |
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
rvm use @global | |
gem i awesome_print | |
echo "require 'awesome_print'" >> ~/.irbrc | |
irb | |
ruby> ap Hash.methods | |
#output | |
[ | |
[ 0] !() Hash (BasicObject) | |
[ 1] !=(arg1) Hash (BasicObject) |
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
. $HOME/.colors | |
if [ $(whoami) != 'root' ]; then | |
user_color=$BGreen | |
else | |
user_color=$BRed | |
fi | |
function parse_git_branch { | |
if ! git rev-parse --git-dir > /dev/null 2>&1; then |
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
# Optional. For rails2.3 proj | |
# ... | |
group :development do | |
# ... | |
gem "pry" | |
gem "pry-doc" | |
gem 'ruby18_source_location' | |
end |
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
current_user=$USER | |
sudo -s | |
usermod -a -G vboxusers $current_user | |
modprobe vboxdrv | |
aptitude update | |
aptitude install dkms | |
/etc/init.d/vboxdrv setup |
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
#!/bin/bash | |
function error_prompt() { | |
echo -e "\e[1;31m Error: \e[0m$1\n" | |
} | |
[[ ! -w $(dirname $1) ]] && error_prompt "No access to designed folder/file" && exit 1 | |
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout $1.key -out $1.crt | |
exit 0 |
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
!!! 5 | |
/[if lt IE 7] <html lang="en" class="no-js ie6"> | |
/[if IE 7 ] <html lang="en" class="no-js ie7"> | |
/[if IE 8 ] <html lang="en" class="no-js ie8"> | |
/[if IE 9 ] <html lang="en" class="no-js ie9"> | |
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]--> | |
%head | |
%meta{:charset => "utf-8"}/ | |
/ | |
Always force latest IE rendering engine (even in intranet) & Chrome Frame |
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
var parser = document.createElement('a'); | |
parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
parser.protocol; // => "http:" | |
parser.hostname; // => "example.com" | |
parser.port; // => "3000" | |
parser.pathname; // => "/pathname/" | |
parser.search; // => "?search=test" | |
parser.hash; // => "#hash" | |
parser.host; // => "example.com:3000" |
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
#Model | |
@user.should have(1).error_on(:username) # Checks whether there is an error in username | |
@user.errors[:username].should include("can't be blank") # check for the error message | |
#Rendering | |
response.should render_template(:index) | |
#Redirecting | |
response.should redirect_to(movies_path) |