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
Ramaze::Cache.options.session = Ramaze::Cache::MemCache.using( | |
compression: false, | |
username: ENV['MEMCACHE_USERNAME'], | |
password: ENV['MEMCACHE_PASSWORD'], | |
servers: ENV['MEMCACHE_SERVERS'].split(','), | |
) |
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 | |
# Usage: | |
# xgrep.rb '//load[@module]/@module' autoload_configs/modules.conf.xml | |
require 'nokogiri' | |
xpath = ARGV[0] | |
files = ARGV[1..-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
callbackData = [] | |
styles = {normal: "burnbit_normal", compact: "burnbit_compact"} | |
hasClass = (tag, name) -> | |
tag.className.match(new RegExp("(\\s|^)" + name + "(\\s|$)")) | |
addClass = (tag, name) -> | |
tag.className += " #{name}" unless hasClass(tag, name) | |
fillDetails = (tag, seeds, peers) -> |
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/ruby | |
def ask(question, retries = 3) | |
fail "Failed to get user input" if retries <= 0 | |
print question | |
if got = gets | |
got.strip | |
else |
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 'sqlite3' | |
sdb = SQLite3::Database.new('net-a-porter.sqlite3') | |
ddb = SQLite3::Database.new('net-a-porter-backup.sqlite3') | |
b = SQLite3::Backup.new(ddb, 'main', sdb, 'main') | |
begin | |
b.step(1) | |
end while b.remaining > 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
class BigDecimal | |
constructor: (number, @precision) -> | |
@number = @gobble(number) | |
plus: (other) -> | |
@bd @number + @gobble(other) | |
minus: (other) -> | |
@bd @number - @gobble(other) |
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 'open-uri' | |
require 'yaml/store' | |
require 'nokogiri' | |
doc = Nokogiri(open('http://namebit.org')) | |
current = doc.at('#blocks_found').text.to_i | |
YAML::Store.new('namebit.yaml').transaction do |store| | |
if previous = store[:previous] | |
case current <=> previous |
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 'tempfile' | |
def check_authorized_keys(keyfile) | |
valid = false | |
File.foreach(keyfile).map do |line| | |
if line =~ /^ssh/ | |
Tempfile.open('key') do |keyfile| | |
keyfile.write(line) | |
keyfile.flush | |
@result = %x[echo #{keyfile.path} | ssh-keygen -l 2>&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
Rubinius Crash Report #rbxcrashreport | |
Error: signal SIGABRT | |
[[Backtrace]] | |
rbx[0x48737f] | |
/lib/libc.so.6(+0x34780)[0x7fb0dbc69780] | |
/lib/libc.so.6(gsignal+0x35)[0x7fb0dbc69705] | |
/lib/libc.so.6(abort+0x17b)[0x7fb0dbc6ab7b] | |
rbx[0x48d75a] |
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 'json' | |
require 'time' | |
data = select_from_db.to_a | |
out = { | |
:item => data.map{|key, value| value.inspect }, | |
:axisx => [ | |
data.first.first, | |
data[data.size / 2].first, |