Skip to content

Instantly share code, notes, and snippets.

View alloy's full-sized avatar

Eloy Durán alloy

View GitHub Profile
@alloy
alloy / 0_reuse_code.js
Created January 30, 2014 13:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@alloy
alloy / 4.rb
Last active August 29, 2015 14:07 — forked from anonymous/4.rb
module ProMotion
class StaticPageView < PageView
def self.method_missing(method_name, obj_or_klass, *args)
options = args.last if args.last.is_a?(Hash)
options ||= {}
# then do rest
end
end
end
# Option 1
info = if publication
"Title: #{ publication.title } (ID: #{ publication.id })"
else
'N/A'
end
# Option 2
info = case publication
when Publication then puts "Title: #{ publication.title } (ID: #{ publication.id })"
@alloy
alloy / gist:6339
Created August 20, 2008 08:07 — forked from mmower/gist:6338
def f(&b)
var_inside_method = :foo
binding_of_this_method = binding
binding_of_block = b.binding
binding_inside_block = b.call
eval "p local_variables", binding_of_this_method
eval "p local_variables", binding_of_block
eval "p local_variables", binding_inside_block
@alloy
alloy / gist:22408
Created November 5, 2008 19:33 — forked from tenpaiyomi/gist:22407
class MenuBarController
def initialize
# Create our status bar for the application
puts "Initializing....."
# menuZone = NSMenu.menuZone()
# menu = NSMenu.allocWithZone(menuZone)
menuItem = NSStatusBar.systemStatusBar.statusItemWithLength(NSVariableStatusItemLength)
# And set it's details
require 'time'
git = ARGV.shift
svn = ARGV.shift
class Git2SVN
def initialize(git, svn)
@git = git
@svn = svn
@repo = File.expand_path File.join(@svn, "repo")
@alloy
alloy / gist:189360
Created September 19, 2009 00:05 — forked from mattetti/gist:189283
require 'rubygems'
require 'active_support'
def rates
o = Object.new
def o.summer_months_nbr
[6, 7, 8, 9]
end
o
end
# Install kicker on osx: sudo gem install kicker --source http://gemcutter.org
#
# Place a `.kick' file with this code in the root of your project, which contains the file to watch.
# Then start running kicker from the project root: $ kicker
module Mockup
FILE_TO_WATCH = 'mockup-1.psd'
def self.last_exported_version
FileUtils.mkdir_p 'output'
@alloy
alloy / .kick
Created November 6, 2009 10:12 — forked from stepheneb/.kick
# Uses the kicker gem, a file-change watcher, using OS X FSEvents:
#
# http://github.com/alloy/kicker
# gem install kicker -s http://gemcutter.org
#
# to send a reload command via Drb to a running spork_server:
#
# http://github.com/timcharper/spork/
# gem install spork
#
** Execute stdlib:build
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "rbconfig.rb" -o "./rbconfig.rbo"
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "lib/date.rb" -o "lib/date.rbo"
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "lib/date/format.rb" -o "lib/date/format.rbo"
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "lib/erb.rb" -o "lib/erb.rbo"
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "lib/fileutils.rb" -o "lib/fileutils.rbo"
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "lib/irb.rb" -o "lib/irb.rbo"
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "lib/irb/cmd/chws.rb" -o "lib/irb/cmd/chws.rbo"
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "lib/irb/cmd/fork.rb" -o "lib/irb/cmd/fork.rbo"
./miniruby -I. -I./lib bin/rubyc --internal --arch i386 --arch x86_64 -C "lib/irb/cmd/help.rb" -o "lib/irb