This file contains 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
var refresh_element = $('#refresh')[0]; | |
if (refresh_element) { | |
$(refresh_element).data('refresh', 1); | |
setInterval(function() { | |
if ($(refresh_element).data('refresh')) | |
$(refresh_element).load(window.location.href + ' #refresh'); | |
}, 5000); |
This file contains 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 :db do | |
namespace :sequences do | |
desc 'Brings Postgres database sequences into sync with MAX(id)' | |
task sync: :environment do | |
ActiveRecord::Base.connection.execute("SET search_path TO public") | |
updates = ActiveRecord::Base.connection.select_rows(%Q{ | |
SELECT 'SELECT setval('''||_schema||'.'||_seq||''', (SELECT MAX('||_column||') FROM '||_schema||'.'||_table||')+1); ' AS updatestring | |
FROM ( | |
SELECT n.nspname AS _schema, |
This file contains 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 are_okay?(list) | |
list.all? do |i| | |
begin | |
# Arbitrary method call | |
i.floor | |
true | |
rescue | |
# Should rescue from known exception (or Pokemon capture) |
This file contains 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 | |
require 'benchmark' | |
COUNT = 1000 | |
LOOP = 1000 | |
def case_method_rb | |
[ | |
"def case_method(x)", |
This file contains 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 pm(object) | |
identifiers = %w[ + - > ] | |
list = | |
case (object) | |
when Class: | |
puts "#{object} (Class)" | |
[ | |
(object.methods.sort - Class.methods), | |
(object.private_methods.sort - Class.private_methods), |
This file contains 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
HTTP/1.0 500 Internal Server Error | |
Date: Mon, 02 Mar 2009 23:26:11 GMT | |
Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8e-fips-rhel5 | |
Set-Cookie: PHPSESSID=98bef3ac7d4ff6ba2c97822d2de167ee; path=/ | |
Expires: Thu, 19 Nov 1981 08:52:00 GMT | |
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 | |
Pragma: no-cache | |
Set-Cookie: kaboom_playspacefinder=connect.kaboom.org%2C189.182.114.45%2C98bef3a | |
c7d4ff6ba2c97822d2de167ee; expires=Tue, 03-Mar-2009 00:26:11 GMT; domain=kaboom. | |
org |
This file contains 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 pm(object) | |
identifiers = %w[ + - > # ] | |
list = | |
case (object) | |
when Class: | |
puts "#{object} (Class)" | |
[ | |
(object.methods.sort - Class.methods), | |
(object.private_methods.sort - Class.private_methods), |
This file contains 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 | |
class Array | |
def unique_by | |
inject(Hash.new(0)) do |h, i| | |
h[yield(i)] += 1 | |
h | |
end.size == size | |
end | |
end |
This file contains 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 Hash | |
def dig(*path) | |
path.inject(self) do |location, key| | |
location.respond_to?(:keys) ? location[key] : nil | |
end | |
end | |
end |
This file contains 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 | |
require File.dirname(__FILE__) + '/../config/environment' | |
conn = ActiveRecord::Base.connection | |
STDOUT.sync = true | |
while (true) | |
print "\e[;H" |