def wrap(string, before: "<", after: ">")
"#{before}#{string}#{after}" # no need to retrieve options from a hash
end
# optional
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
install_package "jruby-1.6.8.dev" "http://ci.jruby.org/snapshots/release/jruby-bin-1.6.8.dev.tar.gz" jruby |
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 Markov | |
attr_reader :order, :phrases | |
def initialize(corpus=[], order=3) | |
@order = order | |
@phrases = Hash.new {|h,k| h[k] = []} | |
add(corpus) | |
end | |
def add(corpus) |
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
import System.IO | |
import Data.List | |
import qualified Data.Map as M | |
import System.Random | |
import Data.Maybe | |
import Control.Applicative | |
main = do | |
contents <- readFile "messages.txt" | |
gen <- getStdGen |
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 "pr_geohash" | |
module GeoHash | |
RADIUS_OF_THE_EARTH = 6371 | |
RADIANS_CONVERSION_FACTOR = 180 / Math::PI | |
# decode geohash to a latitude/longitude point in the centre of the | |
# bounding box described by the geohash | |
def decode_point(geohash) |
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
/*jslint vars: true */ | |
// adapted from http://wiki.openstreetmap.org/wiki/Mercator#JavaScript | |
(function () { | |
var project = {}; | |
if (typeof exports === "object") { | |
module.exports = project; | |
} else { | |
this.project = project; |
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
# Ruby 2.0.0 preview 1 highlights | |
# A few examples of the highlights given in | |
# http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-dev/46348 | |
# Refinements | |
# =========== | |
# create a namespaced refinement | |
module NumberQuery |
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 "time" | |
# Usage: | |
# | |
# SphinxQueryLog.each("path/to/query.log") do |entry| | |
# # do stuff with entry | |
# end | |
# | |
class SphinxQueryLog |
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 "net/http/persistent" | |
require "net/http/pipeline" | |
class DeferredProxy < BasicObject | |
def initialize(&generator) | |
@generator = generator | |
end | |
def method_missing(*args, &block) | |
@source ||= @generator.call |
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 sh | |
set -e | |
dot_env=`cat .env` | |
env $dot_env $@ |