Skip to content

Instantly share code, notes, and snippets.

#! /usr/bin/ruby
require 'svn/client'
require 'tempfile'
# (1) get the data
file = 'tmp.marshal'
dat = nil
begin
open file, 'rb' do |fp|
dat = Marshal.load fp
@technoweenie
technoweenie / minimal-logger.coffee
Created March 9, 2011 20:25
Minimal node.js logger
# logger = require('logger').create()
# logger.info("blah")
# => [2011-3-3T20:24:4.810 info (5021)] blah
# logger.debug("boom")
# =>
# logger.level = Logger.levels.debug
# logger.debug(function() { return "booom" })
# => [2011-3-3T20:24:4.810 error (5021)] booom
class Logger
constructor: (options) ->
http = require 'http'
server = http.createServer (req, res) ->
res.writeHead 200, {'Content-Type': 'text/plain'}
res.end 'Hello World\n'
server.listen 8124, "127.0.0.1", () ->
console.log 'Server running at http://127.0.0.1:8124/'
@isaacs
isaacs / callbacksarehard.js
Created January 12, 2011 02:29
let's go shopping!
// before
mainWindow.menu("File", function(err, file) {
if(err) throw err;
file.openMenu(function(err, menu) {
if(err) throw err;
menu.item("Open", function(err, item) {
if(err) throw err;
item.click(function(err) {
if(err) throw err;
mainWindow.getChild(type('Window'), function(err, dialog) {
@mperham
mperham / gist:558145
Created August 30, 2010 22:23 — forked from zzak/gist:558001
get '/' do
dc = Dalli::Client.new('localhost:11211')
@info = dc.fetch("info-#{userid}-#{repoid}") do
HTTParty.get("#{base_uri}/repos/show/#{userid}/#{repoid}"))
end
@collaborators = dc.fetch("collaborators-#{userid}-#{repoid}") do
HTTParty.get("#{base_uri}/repos/show/#{userid}/#{repoid}/collaborators"))
end
@raggi
raggi / oldcodes.rb
Created August 19, 2010 21:06
happy whyday
p(%|#{<<-''}|[?\0...-0x0_2]<<% == <<%< ><<%&#{?../ 0.0_0 }&)
A Big Number Divided By Zero
ruby &= { :spirit => :creative }
A = [8, -21, 8, 2].zip(self.inspect.scan(/./)).map { |a,b| (b[0] - a).chr }.join
B = <<-B
011010000111010001110100011100000011101000101111001011110110011101101001011101
000110100001110101011000100010111001100011011011110110110100101111011000100111
001001111001011000010110111001110111011011110110111101100100011100110010111101
101011011010010111010001110100011110010010111101110010011000010111011100101111
011011010110000101110011011101000110010101110010001011110110001001101001011011
10001011110110101101101001011101000111010001111001
B
require %w[6f70656e2d757269].pack('H*')
require 'rubygems'
require 'pathname'
require 'rails/all'
class SmallNSexy < Rails::Application
config.session_store :cookie_store, :key => '_omg_session'
config.secret_token = '1319d8ccf1b9bfbdefcb6aa380a044ce'
# ^ because -> http://twitter.com/wycats/status/13898343700
class Page