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
| # -*- 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 |
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
| 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 = [] |
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/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. |
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
| #!/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 |
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
| # -*- 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: |
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
| 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) | |
| ) |
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
| module ActAsCsv | |
| def self.included(base) | |
| base.extend ClassMethods | |
| end | |
| module ClassMethods | |
| def act_as_csv | |
| include InstanceMethods | |
| end | |
| end |
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 | |
| # 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): |
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
| open util/ordering[Date] | |
| sig Organizer { | |
| members : set Player, | |
| } | |
| fun games[o : Organizer] : set Tournament { | |
| Tournament <: organizer.o | |
| } |
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
| 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 | |
| } |