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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
#!/usr/bin/env ruby | |
def flood(*heights) | |
stack = [] | |
max = 0 | |
volume = 0 | |
heights.each do |height| | |
level = [max, height].min | |
count = 0 |
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 (location.hostname.indexOf('proline.pl') != -1) { | |
window.opera.addEventListener('BeforeScript', function(e) { | |
e.element.text = e.element.text.replace(/\.(focus\s*\(\))/g, "/* $1 -- commented by userscript */"); | |
}, false); | |
} |
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; |
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
require "bundler" | |
Bundler.setup(:default) | |
require "cramp" | |
require "http_router" | |
require "thin" | |
class HomeController < Cramp::Action | |
def before_start | |
if params[:password] != "foo" |
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
Convert params in form: | |
"product_suppliers_attributes"=>{ | |
"0"=>{"id"=>"2", "_destroy"=>"false", "supplier_id"=>"1"}, | |
"1"=>{"id"=>"3", "_destroy"=>"false", "supplier_id"=>"3"} | |
} | |
to form: | |
"product_suppliers_attributes"=>[ |
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
[email protected]/7 ~/Code/rolldice | |
23:02:57 % ./rdp 1d6 2d6 3d6 | |
1d6 | |
1d6+0 | |
min: 1, max: 6, avg: 3.5 | |
| # | cnt | cumulative distribution | probability mass | | |
+===+=====+==========================================+==========================================+ | |
| 1 | 1 | ###### | ###### | | |
| 2 | 1 | ############# | ###### | | |
| 3 | 1 | #################### | ###### | |
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
namespace :delayed_job do | |
desc "*HACK* Restart the delayed_job process" | |
task :restart do | |
stop | |
enforce_stop_delayed_job | |
start | |
end | |
# Send SIGTERM to delayed_job associated with current logfile and then | |
# wait for every delayed_job to finish |
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
This example shows how to setup an environment running Rails 3 beta under 1.9.1 with a 'rails3' gem set. | |
∴ rvm update --head | |
# ((Open a new shell)) or do 'rvm reload' | |
# If you do not already have the ruby interpreter installed, install it: | |
∴ rvm install 1.9.1 | |
# Switch to 1.9.1 and gemset rails3, create if it doesn't exist. | |
∴ rvm --create use 1.9.1@rails3 |
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
/* | |
* How to build a Google Map and bind a SearchControl to it and put markers | |
* on the map for each result we receive. | |
*/ | |
// First, we have to load the APIs. | |
google.load('maps' , '2'); | |
google.load('search' , '1'); | |
// Global variables we will set in OnLoad |
NewerOlder