Skip to content

Instantly share code, notes, and snippets.

@sr
sr / gist:288535
Created January 28, 2010 07:52
ICB chat protocol
# ICB Protocol
Last Modified: Sat Aug 4 01:19:36 PDT 2001 by [falcon@icb.net][1]
[1]: mailto:falcon@icb.net
## Basic Packet Layout:
The basic unit ICB clients and server communicate with is a packet with the
following layout:
@sr
sr / heroku-gemfile.rb
Created October 11, 2009 16:06
Convert bundler's Gemfile into Heroku's .gems
def disable_rubygems; nil; end
def source(s); $src = s unless s[/gemcutter/] end
def gem(n, v)
if Hash === v
$stderr.puts "ignoring git gem #{n}"
return
end
puts "#{n} -v#{v}#{$src ? " -s#{$src}": ""}"
end
load ARGV[0] || "Gemfile"
@sr
sr / todo
Created July 31, 2009 23:16 — forked from vangberg/todo
#!/bin/sh
# Best To-Do List. Ever.
#
# Usage:
# 1. Add a new item to list: `todo This needs to be fixed`
# 2. Edit the to-do list: `todo -e`
# 3. Show the current to-do's: `todo`
if [[ $1 ]]; then
if [ $1 = "-e" ]; then
@sr
sr / gist:151557
Created July 21, 2009 20:02
Client side caching for net/http using rack/client and rack/cache
require "rack/client"
require "rack/cache"
require "rack/test"
app = Rack::Builder.new {
use Rack::Cache,
:verbose => true,
:metastore => "heap:/",
:entitystore => "heap:/"
run Rack::Client
@sr
sr / dwm-bar.io
Created July 4, 2009 19:27
my dwm status bar (in both Io and Ruby)
#!/usr/bin/env io
date := Date now asString("%Y-%m-%d %H:%M:%S")
wifi := File clone openForReading("/proc/net/wireless") readLines \
at(2) split at(5) removeAt(2) asString
mpd := method(
File clone openForReading("/home/simon/.mpd/state") foreachLine(i, line,
parts := line split(":")
if(parts at(0) == "state", state := parts at(1))
@sr
sr / Markdown in awk(1)
Created May 21, 2009 14:14
Markdown in awk(1)
#!/bin/awk -f
# md2html.awk
# by: Jesus Galan (yiyus) <yiyu.jgl@gmail>, May 2009
# Usage:
# md2html file.md > file.html
# Options: -v esc=false to not escape html
function newblock(nblock){
if(text)
@sr
sr / gist:108184
Created May 7, 2009 16:08
Crazy test/unit + rack/test hax
require "test/unit"
require "rack/test"
require "contest"
require "sinatra/base"
class MyApp < Sinatra::Base
set :environment, :test
get "/" do
"Hi, #{params["name"]}."
@sr
sr / gist:91275
Created April 7, 2009 15:07
Hax integrity to refresh the page
#!/usr/bin/env ruby
require "rubygems"
require "integrity"
class Refresher
JS = <<-EOS
<script type="text/javascript">
//<![CDATA[
setTimeout('location.reload()', %s * 1000)
//]]>
@sr
sr / test.rb
Created February 24, 2009 03:00 — forked from brynary/gist:69372
module Rack
module Test
module Session
attr_reader :last_response
attr_reader :last_request
alias_method :response, :last_response
alias_method :request, :last_request
def initialize(app)
@sr
sr / atomize
Created February 19, 2009 20:20
my retarded tumblog
#!/usr/bin/env bash
cat <<EOF
<entry>
<title>Omnifaria $1</title>
<published>$(date --utc)</published>
<updated>$(date --utc)</updated>
<content type="xhtml"><div>$(cat | ./src/markdown)</div></content>
</entry>
EOF