This file contains 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 re | |
# match requires the entire string to match, while search will | |
# find a partial match | |
assert re.match("\d+", "123") | |
assert not re.match("\d+", "hello 123") | |
assert re.search("\d+", "123") | |
assert re.search("\d+", "hello 123") |
This file contains 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 Text.ParserCombinators.Parsec | |
import System.Environment (getArgs) | |
import Safe | |
data Expr = | |
Var Name -- variable | |
| App Expr Expr -- application | |
| Lambda Name Expr -- lambda abstraction | |
deriving | |
(Eq,Show) |
This file contains 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 csv | |
""" Read a CSV file of points. | |
Assumes each line of the file is a CSV list of coordinates, which are parsed as | |
floats. | |
""" | |
def read_coords(fname): | |
with open(fname, 'rb') as f: | |
points = [] |
This file contains 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
// ==UserScript== | |
// @name jQuery For Chrome (A Cross Browser Example) | |
// @namespace jQueryForChromeExample | |
// @include * | |
// @author Erik Vergobbi Vold | |
// @description This userscript is meant to be an example on how to use jQuery in a userscript on Google Chrome. | |
// ==/UserScript== | |
// a function that loads jQuery and calls a callback function when jQuery has finished loading | |
function addJQuery(callback) { |
This file contains 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 https://github.com/LearnBoost/Socket.IO/wiki/Migrating-0.6-to-0.7+ | |
// saving the socket id | |
var sid = socket.id | |
// sending a message to a particular socket | |
io.socket(sid).emit("my event", [args]) |
NewerOlder