This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Array | |
alias_method :push!, :push | |
def push(*els) | |
return self + [*els] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-if RAILS_ENV == 'development' | |
:javascript | |
$(function() { | |
var notify = function(icon, title, body) { | |
if (window.webkitNotifications.checkPermission() == 0) { | |
var popup = window.webkitNotifications.createNotification( | |
icon, title, body); | |
popup.show(); | |
return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-if RAILS_ENV == 'development' | |
:javascript | |
$(function() { | |
var notify = function(icon, title, body) { | |
if (window.webkitNotifications.checkPermission() == 0) { | |
var popup = window.webkitNotifications.createNotification( | |
icon, title, body); | |
popup.show(); | |
return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Got this: | |
A B | |
o---o----o---o---o---o---o topic | |
/ / | |
-------o---o---o---o master | |
C | |
Want this: | |
A B |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I decide to work on a new feature, so I create a branch, topic. | |
o---o master | |
\ | |
o---o---o---o topic | |
I am not yet finished working on my feature when I have to make some bugfixes to master | |
o---o---o---o master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def counter(start=0, increment=1) | |
lambda do | |
val = start | |
start += increment | |
val | |
end | |
end | |
result = counter(10,2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppServer | |
attr_accessor :port, :admin_password | |
end | |
class Configuration | |
attr_accessor :tail_logs, :max_connections, :admin_password | |
def initialize | |
@app_server = AppServer.new | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConfigurationClass | |
def self.config_object(name, accessor, *methods) | |
class_eval <<-EOS | |
class #{name} | |
attr_accessor *#{methods.inspect} | |
end | |
def #{accessor} | |
@#{accessor} ||= #{name}.new | |
yield @#{accessor} if block_given? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Step1: install dotjs: https://github.com/defunkt/dotjs | |
//Step2: create files (default.js, procrastinate.js) | |
//Step3: symlink (see procrastinate.sh) | |
//Step4: stop faffing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Loaded from somewhere | |
module MyStuff | |
def my_method | |
puts 'hello' | |
end | |
end | |
if "irb" == $0 | |
include MyStuff | |
end |