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 'stringio' | |
module EM::Bittorrent | |
module Benc | |
def self.decode(input) | |
Stream.new(input).decode | |
end | |
class Stream | |
def initialize(input) |
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
// I'm confused about enveloping and 'blank frames'. | |
// One example from the ZMQ guide seems to have each envelope | |
// separated by an empty frame, and the other has one empty | |
// frame to deliminate the entire envelope stack. Which is | |
// correct? Or are there two different things going on here? | |
// LRU Queue example | |
s_sendmore (backend, worker_queue [0]); | |
s_sendmore (backend, ""); | |
s_sendmore (backend, client_addr); |
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
# Script to watch a directory for any changes to a haml file | |
# and compile it. | |
# | |
# USAGE: ruby haml_watch.rb <directory_to_watch> | |
# | |
require 'rubygems' | |
require 'fssm' | |
directory = File.join(File.dirname(__FILE__), ARGV.first) | |
FSSM.monitor(directory, '**/*.haml') do |
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
irb(main):001:0> require 'maruku' | |
=> true | |
irb(main):002:0> s = File.read('maruku-test') | |
=> "* Abacus\n * answer\n* Bubbles\n 1. bunk\n 2. bupkis\n * BELITTLER\n 3. burper\n* Cunning\n" | |
irb(main):003:0> doc = Maruku.new(s) | |
=> md_el(:document,[ | |
md_el(:ul,[ | |
md_el(:li,[md_par(["Abacus * answer"])],{:want_my_paragraph=>false},[]), | |
md_el(:li,[ | |
md_par(["Bubbles"]), |
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 | |
# | |
# | |
# Quick and dirty script to extract some statistics about | |
# Rails core contributers. | |
# | |
# Usage: git_core_stats <path to rails git project> | |
# Example: git_core_stats ~/code/rails | |
# | |
# OR |
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
From d4ed463815b8c7afcf95500a73754f2bca6b1b13 Mon Sep 17 00:00:00 2001 | |
From: Blake Smith <[email protected]> | |
Date: Tue, 29 Jun 2010 23:43:26 -0500 | |
Subject: [PATCH] Fix garbled UTF-8 characters | |
--- | |
.../2010-01-16-fully-document-your-datamapper.html | 2 +- | |
1 files changed, 1 insertions(+), 1 deletions(-) | |
diff --git a/_posts/2010-01-16-fully-document-your-datamapper.html b/_posts/2010-01-16-fully-document-your-datamapper.html |
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
# An example Jekyll Liquid tag. Utilizes the new plugin system. | |
# | |
# 1. Make a _plugins directory in your jekyll site, and put this class in a file there. | |
# 2. In anyone of your pages, you can use the 'render_time' liquid tag like so: | |
# {% render_time Page generated at: %} | |
module Jekyll | |
class RenderTimeTag < Liquid::Tag | |
def initialize(tag_name, text, tokens) |
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
# An example Jekyll generator. Utilizes the new plugin system. | |
# | |
# 1. Make a _plugins directory in your jekyll site, and put this class in a file there. | |
# 2. Upon site generation, version.html will be created in your root destination with | |
# # the version of Jekyll that generated it | |
module Jekyll | |
class VersionReporter < Generator | |
safe true |
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
# An example Jekyll converter. Utilizes the new plugin system. | |
# | |
# | |
# 1. Make a _plugins directory in your jekyll site, and put this class in a file there. | |
# 2. Any file in the _posts directory ending in .upcase will be processed using this converter. | |
module Jekyll | |
class UpcaseConverter < Converter | |
safe true |
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 'rubygems' | |
require 'inline' | |
class MyTestInC | |
inline do |builder| | |
builder.c <<-EOF | |
long factorial(int max) { | |
int i=max, result=1; | |
while (i >= 2) { | |
result *= i--; |