Skip to content

Instantly share code, notes, and snippets.

View sfate's full-sized avatar
πŸ‡ΊπŸ‡¦
Glory to Ukraine, Glory to the Nation, fuck the russian federation! :feelsgood:

Oleksii Bobyriev sfate

πŸ‡ΊπŸ‡¦
Glory to Ukraine, Glory to the Nation, fuck the russian federation! :feelsgood:
View GitHub Profile
@sfate
sfate / rc.sh
Created July 11, 2012 15:09 — forked from indirect/rc.sh
rails console alias for both 2 and 3
# 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
}
@sfate
sfate / init_rails3_app.sh
Created July 11, 2012 15:10 — forked from indirect/steps.sh
creating an edge rails3 app with RVM
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
@sfate
sfate / awesome_print.sh
Created July 11, 2012 15:30
use awesome_print gem in irb
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)
@sfate
sfate / .bash.sh
Last active July 16, 2018 04:39
Change default bash prompt
. $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
@sfate
sfate / Gemfile
Last active October 7, 2015 05:07
Playing around with settings for ruby console
# Optional. For rails2.3 proj
# ...
group :development do
# ...
gem "pry"
gem "pry-doc"
gem 'ruby18_source_location'
end
@sfate
sfate / gist:3206604
Created July 30, 2012 12:40
Virtualbox Fix: unsupported kernel driver
current_user=$USER
sudo -s
usermod -a -G vboxusers $current_user
modprobe vboxdrv
aptitude update
aptitude install dkms
/etc/init.d/vboxdrv setup
@sfate
sfate / gist:3208413
Created July 30, 2012 17:08
Generate ssl self-signed key
#!/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
@sfate
sfate / hamlhtml5boilerplate.html.haml
Created August 27, 2012 12:16 — forked from neiled/hamlhtml5boilerplate.html.haml
My haml version of the html 5 boiler plate code
!!! 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) &amp; Chrome Frame
@sfate
sfate / uri.js
Created September 6, 2012 09:41 — forked from nhocki/uri.js
URI Parsing with Javascript
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"
@sfate
sfate / rspec_rails_cheetsheet.rb
Created September 12, 2012 08:29 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#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)