Skip to content

Instantly share code, notes, and snippets.

@xarimanx
xarimanx / gist:1798774
Created February 11, 2012 11:04 — forked from delano/gist:845643
Fix for "Errno::ETIMEDOUT: Operation timed out - connect(2)" when installing gems
# A DNS change to Rubygems.org is causing lingering issues. Namely,
# rubygems.org and production.s3.rubygems.org are still pointing to
# the old address. See:
# http://twitter.com/#!/gemcutter/status/30666857698557952
# The symptoms:
# $ gem install benelux --version 0.5.17
# ERROR: Could not find a valid gem 'benelux' (= 0.5.17) in any repository
# ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
std_opts = "--strict --tags ~@wip --tags ~@pending"
std_format = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'}"
%>
default: <%= std_opts %> <%= std_format %> features
wip: --tags @wip --tags ~@pending --wip features
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
detail: --tags ~@pending --wip features
@xarimanx
xarimanx / gist:1798861
Created February 11, 2012 11:23 — forked from oleksiilevzhynskyi/gist:1349543
Date Time Format in RUBY
Format meaning:
%a - The abbreviated weekday name (``Sun'')
%A - The full weekday name (``Sunday'')
%b - The abbreviated month name (``Jan'')
%B - The full month name (``January'')
%c - The preferred local date and time representation
%d - Day of the month (01..31)
%H - Hour of the day, 24-hour clock (00..23)
%I - Hour of the day, 12-hour clock (01..12)
@xarimanx
xarimanx / gist:1798862
Created February 11, 2012 11:23 — forked from oleksiilevzhynskyi/gist:1230077
Hot keys in terminal
ctrl+a or Home - Moves the cursor to the start of a line.
ctrl+e or End - Moves the cursor to the end of a line.
ctrl+b - Moves to the beginning of the previous or current word.
ctrl+k - Deletes from the current cursor position to the end of the line.
ctrl+u - Deletes the whole of the current line.
ctrl+w - Deletes the word before the cursor.
@xarimanx
xarimanx / gist:1798863
Created February 11, 2012 11:23 — forked from oleksiilevzhynskyi/gist:1186087
Removing rvm
rvm implode
rm ~/.rvmrc
curl -s https://rvm.beginrescueend.com/install/rvm -o rvm-installer ; chmod +x rvm-installer ; ./rvm-installer --version 1.8.0
;
rvm implode
gem uninstall rvm
@xarimanx
xarimanx / gist:1798864
Created February 11, 2012 11:23 — forked from oleksiilevzhynskyi/gist:1146869
Failed to build gem 'nokogiri' native extension.
sudo apt-get install libxslt1-dev
libxml, libxml-dev, libxslt, libzslt-dev
@xarimanx
xarimanx / gist:1800759
Created February 11, 2012 15:23 — forked from oleksiilevzhynskyi/gist:1258663
How to get git-completion.bash to work on Mac OS X?
sudo port install git-core +bash_completion
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi
GIT_PS1_SHOWDIRTYSTATE=true
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;33m\]\w\[\033[00m\]\[\033[01;31m\]$(__git_ps1 " {%s}")\[\033[00m\]\$ '
@xarimanx
xarimanx / gist:1844502
Created February 16, 2012 12:25 — forked from oleksiilevzhynskyi/gist:1259158
Problem with blame in TextMate
mkdir -p /Library/Application\ Support/TextMate/Bundles
cd !$
git clone git://github.com/timcharper/git-tmbundle.git Git.tmbundle
osascript -e 'tell app "TextMate" to reload bundles'
Ctr+Shift+G => blame
enjoy!
@xarimanx
xarimanx / ruby-prof
Last active December 18, 2015 00:29
ruby-prof
require "ruby-prof"
around_filter :profile
def profile
return yield if params[:profile].nil?
result = RubyProf.profile { yield }
printer = RubyProf::FlatPrinter.new(result)
File.open("profile.txt", "w+") do |f|
printer.print(f, {})
@xarimanx
xarimanx / data_attr_options.rb
Created July 4, 2013 14:48
generate options with custom data attrs
def options_from_collection_for_select_with_data(collection, value_method, text_method, selected = nil, data = {})
options = collection.map do |element|
[element.send(text_method), element.send(value_method), data.map do |k, v|
{"data-#{k}" => element.send(v)}
end
].flatten
end
selected, disabled = extract_selected_and_disabled(selected)
select_deselect = {}
select_deselect[:selected] = extract_values_from_collection(collection, value_method, selected)