Skip to content

Instantly share code, notes, and snippets.

@ymendel
ymendel / gist:839575
Created February 22, 2011 22:34
git_current_branch vs. git_current_head
git_current_branch()
{
git branch 2>/dev/null | awk '/^\* /{print $2}'
}
git_current_head()
{
export BRANCH=`git branch 2>/dev/null | awk '/^\* /{print $2}'`
if [[ $BRANCH = "(no" ]]; then
export BRANCH=`git name-rev --name-only HEAD 2>/dev/null`
% 1.01 (*) Find the last element of a list.
mylast(E, [E]).
mylast(E, [_|T]) :- mylast(E, T).
% 1.02 (*) Find the last but one element of a list.
mypenult(E, [E,_]).
mypenult(E, [_|T]) :- mypenult(E, T).
% 1.03 (*) Find the Kth element of a list.
myindex(H, [H|_], 1).
@ymendel
ymendel / gist:828387
Created February 15, 2011 22:24
fucking indentation, how does it work?
if (i_am_not_an_asshole) {
i_indent_code_reasonably
} elsif (some_other_shit) {
things_happen
} elsif (something_else) {
keep_going
} else {
i_fuck_your_mind
}
>> class Blah
>> def callback(&b) @block = b; end
>> def do_it; @block.call; end
>> end
=> nil
>> b = Blah.new
=> #<Blah:0x511580>
>> n = 10
=> 10
>> b.callback { puts n }
$ echo 'test' | gist
certificate verify failed
Usage: gist [options] [filename or stdin] [filename] ...
Filename '-' forces gist to read from stdin.
-p, --[no-]private Make the gist private
-t, --type [EXTENSION] Set syntax highlighting of the Gist by file extension
-o, --[no-]open Open gist in browser
-m, --man Print manual
-v, --version Print version
-h, --help Display this screen
>> t = Time.now
=> Thu Nov 18 15:19:32 -0600 2010
>> ts = t.strftime('%Y-%m-%dT%H:%M:%S%z')
=> "2010-11-18T15:19:32-0500"
>> Time.parse(ts)
=> Thu Nov 18 14:19:32 -0600 2010
>> ts = t.strftime('%Y-%m-%dT%H:%M:%S%Z')
=> "2010-11-18T15:19:32CST"
>> Time.parse(ts)
=> Thu Nov 18 15:19:32 -0600 2010
$ script/spec spec
Missing these required gems:
nokogiri
You're running:
ruby 1.8.7.174 at /Users/yossef/.rvm/rubies/ree-1.8.7-head/bin/ruby
rubygems 1.3.6 at /Users/yossef/.rvm/gems/ree-1.8.7-head@mapco, /Users/yossef/.rvm/gems/ree-1.8.7-head@global
Run `rake gems:install` to install the missing gems.
$ rake gems:install
def self.wday_bitfield_values
# These values are generated by calculating 2^x, where x is the "wday" (0..6) of a DateTime ...
[ 1, 2, 4, 8, 16, 32, 64 ]
end
I don't know how to quantify the following, but for me it the life blood of a scene that works...
Dr. Cleve Stevens wrote in the Harvard Business Review
Traditional business leaders says, 'I'm the leader Ð you're the follower; I have something you need (money) and you have something I need (labor). Let's make an exchange.' This is like the dance scene organizer who says, ÒI donÕt need your thoughts on how I should run things, I just need your money from registering for my events so I can keep providing for you.Ó
Transformational leaders understand there is something bigger at work. In fact, employees need four key things to be happy:
the need to love and be loved
$ rvm use ruby-1.9.1
info: Using ruby 1.9.1 p378
Cassady:~ yossef$ irb
reruby-1.9.1-p378 > require 'rubygems'
=> false
ruby-1.9.1-p378 > require 'cinch'
=> true
ruby-1.9.1-p378 > bot = Cinch::Bot.new
=> #<Cinch::Bot:0x444914 @logger=#<Cinch::Logger::FormattedLogger:0x4448f8 @output=#<IO:<STDERR>>, @mutex=#<Mutex:0x4448dc>>, @events={:connect=>[[[//], [], #<Proc:0x43b438@/Users/yossef/.rvm/gems/ruby-1.9.1-p378/gems/cinch-1.0.0/lib/cinch/bot.rb:122>]]}, @config=#<OpenStruct server="localhost", port=6667, ssl=false, password=nil, nick="cinch", realname="cinch", verbose=true, messages_per_second=0.5, server_queue_size=10, strictness=:forgiving, message_split_start="... ", message_split_end=" ...", max_messages=nil, plugins=#<OpenStruct plugins=[], prefix="!", options={}>, channels=[], encoding=nil>, @semaphores_mutex=#<Mutex:0x43b4fc>, @semaphores={}, @plugins=[], @callback=#<Cinch::Callback:0x43b48c @bot=#<Cinch::Bot:0x444914 ...>>, @channels=[]>