Minimalist templating.
fs = require 'fs'
coffee = require 'coffee-script'
The render
method returns a template from template text or an
interpolated template if passed a data object. Ex:
{test, ok, arrayEq} = require 'testy' | |
Array::uniq = -> | |
U = {} | |
U[@[i]] = @[i] for i in [0...@length] | |
v for k, v of U | |
flatten = (arr) -> arr.reduce ((x, y) -> x.concat y), [] |
Here's Peter Norvig's treatment of the zebra puzzle from his CS212 course.
import sys | |
sys.path.insert(0, '..') # relative path to MODULE, change as appropriate | |
from MODULE import * # replace MODULE with the name of your module |
See also:
Suppose you have a set of files you want to partition on the basis of the first line in the file.
This script enables you to move a filtered subset (based on the header line) to a target directory.
You specify the pattern in the first line of the files you wish to move. Those files containing the pattern in their header get moved, those without don't.