Skip to content

Instantly share code, notes, and snippets.

View mikz's full-sized avatar

Michal Cichra mikz

View GitHub Profile
@rkumar
rkumar / gist:445735
Created June 20, 2010 10:47
ruby's OptionParser to get subcommands
#!/usr/bin/env ruby -w
## Using ruby's standard OptionParser to get subcommand's in command line arguments
## Note you cannot do: opt.rb help command
## other options are commander, main, GLI, trollop...
# run it as
# ruby opt.rb --help
# ruby opt.rb foo --help
# ruby opt.rb foo -q
# etc
class CucumberExternalResqueWorker
DEFAULT_STARTUP_TIMEOUT = 1.minute
COUNTER_KEY = "cucumber:counter"
class << self
attr_accessor :pid, :startup_timeout
def start
# Call from a Cucumber support file so it is run on startup
return unless Rails.env.cucumber?
@aurelian
aurelian / gist:534568
Created August 18, 2010 12:39
shows what before_filter is executed and where's that filter defined. useful to debug before_filter madness
puts "\033[1;31m=> Loading hacks: #{__FILE__}\033[0m"
module BeforeFilterHacks
def self.included(base)
base.class_eval { alias_method_chain :call, :hacks }
end
def call_with_hacks(controller, &block)
message= if method.kind_of?(Proc)
method.to_s
@karmi
karmi / ElasticSearch.org.Website.Search.FieldNotes.markdown
Created April 8, 2011 17:15
Field notes gathered during installing and configuring ElasticSearch for http://elasticsearch.org

ElasticSearch.org Website Search: Field Notes

These are field notes gathered during installation of website search facility for the ElasticSearch website.

You may re-use it to put a similar system in place.

The following assumes:

#!/usr/bin/env macruby
# encoding: utf-8
CALENDARS = ['Michal Cichra', 'Calendar'] # Set names of calendars to show
before = 3 # days to show before today
after = 10 # days to show after today
today = 'dnes'
@scottmessinger
scottmessinger / gist:1018177
Created June 10, 2011 03:15
Model has no method '_configure'
Relevant Code:::
var Course = Backbone.Model.extend({
url : function(){
var base = 'courses'
if (this.isNew()) return base;
return base + (base.charAt(base.length-1) == '/'?'' : '/') + this.id;
}
})
@shaneog
shaneog / gist:1198248
Created September 6, 2011 17:12
elasticsearch ubuntu 11.04
cd ~
# Install the required JDK
sudo apt-get install openjdk-6-jre-headless
# Download, extract and move ElasticSearch
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.17.6.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
@mikz
mikz / gist:1337933
Created November 3, 2011 22:07
Rate current song in iTunes - Alfred Extension - requires macruby
read -s -r -d '' SCRIPT <<"EOF"
framework 'ScriptingBridge'
rating = ARGV.pop
itunes = SBApplication.applicationWithBundleIdentifier("com.apple.itunes")
track = itunes.currentTrack
track.rating = rating.to_f*20
puts "#{track.artist} - #{track.name} rated #{rating} stars"
EOF
framework "CoreWLAN"
iface = CWInterface.interface
iface.disassociate
wlans = iface.scanForNetworksWithParameters(nil, error: nil)
wlan = wlans.find {|w| w.ssid == "WLAN_724A"}
p [wlan.bssid, wlan.ssid, wlan.securityMode, wlan.wlanChannel.channelNumber]
keys = File.read("./dictionary.txt").lines.to_a.reverse
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#