Skip to content

Instantly share code, notes, and snippets.

View YoniTsafir's full-sized avatar

Yoni Tsafir YoniTsafir

View GitHub Profile
@YoniTsafir
YoniTsafir / gist:1104645
Created July 25, 2011 17:27
mock 0.8 beta1 bug
# Old version:
>>> from mock import MagicMock
>>> a = MagicMock()
>>> a.foo("hello")
<mock.MagicMock object at 0xa40cecc>
>>> a.foo("goodbye")
<mock.MagicMock object at 0xa40cecc>
>>> a.foo.call_args_list
[(('hello',), {}), (('goodbye',), {})]
>>> a.foo.call_args_list[0]
'''
Created on Apr 14, 2011
'''
class LCDCalculator(object):
def calc(self, num1, num2):
return reduce(lambda x, y: x * y, self.smart_union(self.factorize(num1), self.factorize(num2)))
def factorize(self, num):
@YoniTsafir
YoniTsafir / DelayedAssert.java
Created April 3, 2011 19:21
Code Sheriff's Code Examples
public interface ConditionTester {
boolean isTrue();
}
public static void delayedAssert(ConditionTester tester,
long timeout,
long pollingInterval)
throws InterruptedException {
long startTime = System.currentTimeMillis();
#include <iostream>
using namespace std;
void main()
{
int a = 1, b = 2;
int arr[] = {1, 3, 5, a, b};
int *p = arr + 1;
int **q = &p;
int ***crazy = new int**[*(arr + 4)];