Skip to content

Instantly share code, notes, and snippets.

class Array
alias_method :push!, :push
def push(*els)
return self + [*els]
end
end
@latentflip
latentflip / Growl-like popup on JS error.js
Created March 14, 2011 11:41
There may be a better way to do this, but: When writing JS I often make a silly little typo or something that I don't notice unless I: - notice that something seems broken - open Chrome's developer toolbar, which I inevitably closed last time to get
-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;
@latentflip
latentflip / Growl-like popup on JS error.js
Created March 14, 2011 11:42
Gives a growl like popup if a page has an error. Useful under development.
-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;
Got this:
A B
o---o----o---o---o---o---o topic
/ /
-------o---o---o---o master
C
Want this:
A B
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
def counter(start=0, increment=1)
lambda do
val = start
start += increment
val
end
end
result = counter(10,2)
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
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?
//Step1: install dotjs: https://github.com/defunkt/dotjs
//Step2: create files (default.js, procrastinate.js)
//Step3: symlink (see procrastinate.sh)
//Step4: stop faffing
#Loaded from somewhere
module MyStuff
def my_method
puts 'hello'
end
end
if "irb" == $0
include MyStuff
end