Skip to content

Instantly share code, notes, and snippets.

View sanitz's full-sized avatar
👽

Sebastian Sanitz sanitz

👽
View GitHub Profile
import pytest
param = pytest.mark.parametrize
def primes(num):
factors = []
divisor = 1
while num > 1:
divisor += 1
while (num % divisor == 0):
def munge(txt):
if len(txt) <= 3:
return txt
return txt[0] + txt[-2:0:-1] + txt[-1]
def test_three():
assert munge('abc') == 'abc'
@sanitz
sanitz / test_hamcrest.py
Created April 16, 2014 12:29
Two failing tests and examples for the description matched or unmatched items with PyHamcrest.
from hamcrest.core.base_matcher import BaseMatcher
from hamcrest import assert_that, is_not, is_
from datetime import date
class SundayMatcher(BaseMatcher):
def matches(self, item, mismatch_description=None):
return item.weekday() == 6
@sanitz
sanitz / gist:2220279
Created March 27, 2012 21:11
Für Sven
~$ ipython
Python 2.7.2+ (default, Oct 4 2011, 20:06:09)
Type "copyright", "credits" or "license" for more information.
IPython 0.10.2 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
pip install watchdog
watchmedo shell-command -c ./runtests_local.sh -p "*.py" -R
@sanitz
sanitz / Fizzbuzz.coffee
Created October 9, 2011 10:21
Fizzbuzz in CoffeeScript
fizzbuzz = for n in [1..100]
if n % 15 is 0
'fizzbuzz'
else if n % 3 is 0
'fizz'
else if n % 5 is 0
'buzz'
else
n
@sanitz
sanitz / kata.coffee
Created August 29, 2011 14:43
Simple example for ccc-kata
dgram = require "dgram"
server = dgram.createSocket "udp4"
client = dgram.createSocket "udp4"
finish = ->
client.close()
server.close()
process.exit()
@sanitz
sanitz / RomanNumbersTest.java
Created June 28, 2011 18:27
Result of the roman numbers kata in Java
package kata;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
public class RomanNumbersTest {
package kata;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import static org.junit.Assert.*;
call_command('flush', interactive=False, verbosity=0)
call_command('loaddata', filename, verbosity=0, traceback=True)