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 python | |
import re | |
def pyspec(source): | |
def translate(lines): | |
def name(n): | |
return re.sub("_+", "_", re.sub(r"[\s\W]+", "_", n)).strip("_") | |
def on_describe(m): | |
r"""(\s*)describe\s+("[^"]*"|'[^']*'|[^:]+?)\s*:""" |
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
# shell script to copy styled text from textmate to keynote | |
# input: selected text or document, output: discard, key: ctrl+alt+cmd+C | |
ruby -e' | |
require "jcode" | |
$KCODE="U" | |
require "#{ENV["TM_BUNDLE_SUPPORT"]}/lib/doctohtml.rb" | |
require "#{ENV["TM_SUPPORT_PATH"]}/lib/progress.rb" | |
unit = ENV.has_key?("TM_SELECTED_TEXT") ? "selection" : "document" | |
TextMate.call_with_progress(:message => "Creating HTML version of #{unit}…") do | |
print document_to_html( STDIN.read, :include_css => 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
wiki = KVStore("/tmp/wiki.kvstore") | |
with wiki.write_transaction: | |
wiki["home1"] = "This is the home page 1" | |
wiki["home2"] = "This is the home page 2" | |
with wiki.read_transaction: | |
for name in wiki: | |
print name, "=", wiki[name] |
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 ListOfListArray: | |
def __init__(self, width, height, default=None): | |
self.width, self.height = width, height | |
self.values = [[default] * width for i in range(height)] | |
def __getitem__(self, (x, y)): | |
return self.values[y][x] | |
def grow_height(self, dy, default=None): | |
self.height += dy |
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
package sma.python; | |
import java.util.HashMap; | |
import java.util.Map; | |
/** | |
* A minimal python byte code interpreter to run the usual "fib" benchmark. | |
* | |
* <pre> | |
* def fib(n): |
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 random | |
def d(n): | |
r = random.randint(1, n) | |
return r if r < n else r + d(n) | |
def dw(n): | |
return max(d(n), d(6)) | |
def old_rules(n): |
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
>>>> Gherkin <<<< | |
As a developer | |
In Order to find the best scripting solution | |
So that I can compare different implementation languages for Cucumber | |
Given I have 1h of time | |
When I write something about Cucumber | |
Then others should like that |
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
example = """ | |
start | |
{ | |
position1 "-1022.963745,793.409607,8.966581" | |
position2 "-1024.971558,70.542549,416.005066" | |
name "Start" | |
time 0.0 | |
active 1 | |
give | |
{ |
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 RbClass: | |
def __init__(self): | |
self.methods = {} | |
def define_method(self, name, method): | |
self.methods[name] = method | |
def lookup(self, name): | |
return self.methods[name] |
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 __future__ import division | |
from math import trunc | |
from random import random | |
import re | |
TOKENS = re.compile(r'(?<=REM).*|\.?\d+|\w+\$?|[():;=+\-*/]|<[=>]?|>=?|"[^"]*"') | |
class Basic(object): | |
def __init__(self, filename): | |
self.tokens = [] |