This file contains 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
var system = require('system'), | |
env = system.env; | |
/** | |
* Wait until the test condition is true or a timeout occurs. Useful for waiting | |
* on a server response or for a ui change (fadeIn, etc.) to occur. | |
* | |
* @param testFx javascript condition that evaluates to a boolean, | |
* it can be passed in as a string (e.g.: "1 == 1" or "$('#bar').is(':visible')" or | |
* as a callback function. |
This file contains 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
Allows match JSON objects by pattern. Intended for APIs comparison and verification. | |
E.g.: | |
compare( | |
{ a: 1, b: ['x', 'y'] }, // pattern | |
{ a: 42, b: ['first', 'second', 'any', 'last'] } // object for check | |
); |
This file contains 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
Build with: `g++ test.cpp && ./a.out` | |
For editing two files in `vim` run command `:vsplit tree.h`. | |
http://www.cs.swarthmore.edu/help/vim/windows.html |
This file contains 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
// This is a workaround for R# complaining on undefined global variables. | |
// In practice they come from and are defined by Jasmine and Protractor | |
// frameworks, so are not a real issues. | |
// Jasmine | |
var describe = function () { }; | |
var beforeEach = function () { }; | |
var afterEach = function () { }; |
Implementation of algorithm for points compression. For more details see the post: http://barahilia.github.io/blog/computers/2014/10/11/points-on-plane-compression.html.
Given an array of 2D points, each coordinate a 16-bit integer, split them all to squares on 256x256 grid and encode each coordinate with one byte only.
This gits features encoding functions, unit tests and a sample file.
Demonstration of phenomenon, when caller cumulative time can be less than the callee, given it's the only caller. This may happen if callee is generator and caller returns callee object as is. Then profiler sees a lot of time spent in callee and almost no time at caller.
This file contains 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
import functools | |
def tamper(target, attr_name, mock_obj): | |
def decor(func): | |
@functools.wraps(func) | |
def worker(*args, **kwargs): | |
backup = getattr(target, attr_name) | |
try: | |
setattr(target, attr_name, mock_obj) |
This file contains 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
"""Find exit from the fractal maze. | |
See http://puzzling.stackexchange.com/questions/37675/alice-and-the-fractal-hedge-maze | |
""" | |
from unittest import TestCase | |
from Queue import PriorityQueue | |
from collections import defaultdict | |
from itertools import count, product |
This file contains 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
from unittest import TestSuite | |
def print_tests(tests): | |
if isinstance(tests, TestSuite): | |
for child in tests: | |
print_tests(child) | |
else: | |
print tests.id() # package.module.TestClass.test_name |
OlderNewer