Skip to content

Instantly share code, notes, and snippets.

def do_turn(game):
pass
exports.doTurn = function(pw) {
};
@barnash
barnash / bitmap.py
Created May 21, 2014 05:14
Files from the images tirgul
from PIL import Image
from matrix import *
def image2bitmap(path):
''' Given a string 'path' of image file in "real" format (.jpg/.bmp etc.) creates a new file in format .bitmap under the same directory which can then be loaded into class Matrix using Matrix.load() '''
from PIL import Image
image = Image.open(path)
image = image.convert("L")
im = image.load()
w,h = image.size
@barnash
barnash / digest1.js
Created May 3, 2014 07:44
Code from angular - digest loop presentation
function Scope() {
this.$$watchers = [];
this.$$lastDirtyWatch = null;
}
Scope.prototype.$$areEqual = function(newValue, oldValue, valueEq) {
if (valueEq) {
return _.isEqual(newValue, oldValue);
} else {
return newValue === oldValue ||
def our_for(iterable, what_to_do):
iterator = iter(iterable)
while True:
try:
i = next(iterator)
what_to_do(i)
except StopIteration as e:
return
class A:
class Node():
def __init__(self, val):
self.value = val
self.next = None
def __repr__(self):
return "[" + str(self.value) + "," + str(id(self.next)) + "]"
class LinkedList():
def __init__(self):
import random
def hash_table(m):
""" initial hash table, m empty entries """
return [[] for i in range(m)]
def hash_mod(key, mod, func=hash):
return func(key) % mod
def contained(candidate_key, list_of_items):
def count_change(amount, coins):
if amount == 0:
return 1
if len(coins) == 0 or amount < 0:
return 0
return count_change(amount - coins[-1], coins) + \
count_change(amount, coins[:-1])
results = {}
@barnash
barnash / recursion.py
Created December 24, 2013 06:37
קוד מתרגול 8
def my_max(lst):
mv = lst[0]
for i in lst:
if i > mv:
mv = i
return mv
def rmax_oz(lst):
if len(lst) == 1:
return lst[0]
{% extends 'includes/base_header.html' %}
{% from 'includes/links.html' import course_link %}
{% block window_title %}אנשים{% endblock %}
{% block stylesheets %}{{ super() }}
<link rel="stylesheet" type="text/css" href="/static/css/people-list.css" />
{% endblock %}