I hereby claim:
- I am jamis on github.
- I am jamis (https://keybase.io/jamis) on keybase.
- I have a public key whose fingerprint is D6BF 2C78 D257 1F45 892A F160 3E22 BCB7 321F F098
To claim this, I am signing this object:
{- -------------------------------------------------------------------------- | |
- A naive random maze generator. | |
- | |
- $ ghc -o maze Maze.hs | |
- $ maze 10 10 | |
- | |
- Author: Jamis Buck ([email protected]) | |
- ------------------------------------------------------------------------ -} | |
module Main where |
-module(maze). | |
-export([generate/2,north/3,south/3,west/3,east/3,visualize/1]). | |
% Generate and return a maze of width W and height H. | |
generate(W,H) -> try_directions(random:uniform(W)-1, random:uniform(H)-1, directions(), {width,W,height,H,0}). | |
% Returns true if there is a passage north from the given position in the maze. | |
north(X,Y,Maze) -> at(X,Y,Maze) band 2#1 =/= 0. | |
% Returns true if there is a passage south from the given position in the maze. |
__________xxx__________ | |
_______xxx477xxx_______ | |
_____xx544833463xx_____ | |
____x1451114517135x____ | |
___x494967555876685x___ | |
__x37298356739187585x__ | |
__x14784292711822763x__ | |
_x7218553113133428613x_ | |
_x4267252422543281773x_ | |
_x4165111914344319827x_ |
require 'strscan' | |
# expr := term | |
# | term AND expr | |
# | term OR expr | |
# term := value | |
# | atom ':' value | |
# atom := word+ | |
# | quoted_string | |
# value := atom |
I hereby claim:
To claim this, I am signing this object:
class Resources::Assets < Webmachine::Resource | |
def content_types_provided | |
@asset = Application.assets[request.uri.path] | |
if @asset.present? | |
[[@asset.content_type, :to_asset]] | |
else | |
accept = request.headers['Accept'] || "text/html" | |
[[accept.split(/,/).first.split(/;/).first.strip, :to_html]] | |
end |
/* Returns the number of bytes needed to represent the given | |
* Javascript string in UTF-8. */ | |
String.prototype.byteSize = function () { | |
var bytes = 0; | |
for(i = 0; i < this.length; i++) { | |
var charCode = this.charCodeAt(i); | |
if (charCode <= 0x7F) | |
bytes += 1; | |
else if (charCode <= 0x7FF) | |
bytes += 2; |
require 'optparse' | |
module WordPicker | |
def pick | |
self[rand(length)] | |
end | |
LENGTHS = [1] + [2]*3 + [3]*4 + [4]*4 + [5]*4 + [6]*3 + [7]*2 + [8] | |
def sentence | |
words = [] |
# encoding: utf-8 | |
s = "Blah \xe9 blah 헌글" | |
puts "BEFORE" | |
puts "encoding: #{s.encoding}" | |
puts "valid : #{s.valid_encoding?}" | |
puts "text : #{s}" | |
s = s. |
#!/usr/bin/env ruby | |
require 'capistrano/cli' | |
class TranscriptLogger | |
module TranscriptLoggerMetadata | |
attr_accessor :tx_logger_metadata | |
def self.apply_to(object, options={}) | |
object.extend(self) unless object.respond_to?(:tx_logger_metadata) |