Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
import sys
def tracer(frame, event, arg):
print("source: {}\tlineno: {}".format(frame.f_code.co_filename, frame.f_lineno))
with open(frame.f_code.co_filename, 'r') as f:
print(f.readlines()[frame.f_lineno-1][0:-1])
return tracer
def tokenize(s)
s.gsub(/[()]/, ' \0 ').split
end
def read_from(tokens)
raise SyntaxError, 'unexpected EOF while reading' if tokens.length == 0
case token = tokens.shift
when '('
l = []
#!/usr/bin/gprolog --consult-file
fib(1, 1).
fib(2, 1).
fib(N, R) :- N1 is N-1, fib(N1, R1), N2 is N-2, fib(N2, R2), !, R is R1 + R2.
#!/bin/sh
DROPBOX_REPOSITORIES_PATH=`git config dropbox.folder`
eval DROPBOX_REPOSITORIES_PATH=$DROPBOX_REPOSITORIES_PATH
if [ ! "$DROPBOX_REPOSITORIES_PATH" -o ! -d "$DROPBOX_REPOSITORIES_PATH" ]; then
echo "Do \"git config --global dropbox.folder \$HOME/Dropbox/repositories\" first"
exit 1
fi
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
import csv
import os
def calc_b(a):
if a <= 1800000:
return max(a*0.4, 650000)
elif a <= 3600000:
Matrix := List clone
Matrix set := method(x, y, value,
self at(y) atPut(x, value)
)
Matrix get := method(x, y,
self at(y) at(x)
)
module ActAsCsv
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def act_as_csv
include InstanceMethods
end
end
#!/usr/bin/env python
# vim: fileencoding=utf-8
from __future__ import division, absolute_import, print_function, unicode_literals
import os.path
import unicode_csv
import io
writer = unicode_csv.writer(io.open(os.path.expanduser("~/large.csv"), 'w', encoding='cp932'))
row = [unicode(i) for i in range(200)]
for i in range(100000):
open util/ordering[Date]
sig Organizer {
members : set Player,
}
fun games[o : Organizer] : set Tournament {
Tournament <: organizer.o
}
abstract sig Var {
value: Int
}
one sig A, B, C extends Var {}
pred S1 {
A.value > 0 and B.value > 0 and C.value > 0
}