Skip to content

Instantly share code, notes, and snippets.

barahilia / run-jasmine.js
Last active Mar 2, 2017 — forked from dlidstrom/run-jasmine.js
Runs Jasmine tests using PhantomJS. Adapted for use within TeamCity..Compatible with Jasmine 2.0.
View run-jasmine.js
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.
barahilia / json-pattern-matcher
Last active Aug 29, 2015
JSON pattern matching
View json-pattern-matcher
Allows match JSON objects by pattern. Intended for APIs comparison and verification.
{ a: 1, b: ['x', 'y'] }, // pattern
{ a: 42, b: ['first', 'second', 'any', 'last'] } // object for check
barahilia / tdd-trees-comp-c++
Last active Aug 29, 2015
TDD for trees comparison in C++
View tdd-trees-comp-c++
Build with: `g++ test.cpp && ./a.out`
For editing two files in `vim` run command `:vsplit tree.h`.
barahilia / workaround.js
Created Sep 9, 2014
Workaround for R# complaining on use of an implicitly declared global variable
View workaround.js
// 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 () { };
barahilia /
Created Oct 12, 2014
Kramdown yellow highlight
Fill details here...
barahilia /
Last active Aug 29, 2015
Points compression algo

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.

barahilia /
Last active Jul 28, 2016
Tampering class method in python (temporarily replacing/mocking/faking for unit test)
import functools
def tamper(target, attr_name, mock_obj):
def decor(func):
def worker(*args, **kwargs):
backup = getattr(target, attr_name)
setattr(target, attr_name, mock_obj)
"""Find exit from the fractal maze.
from unittest import TestCase
from Queue import PriorityQueue
from collections import defaultdict
from itertools import count, product
from unittest import TestSuite
def print_tests(tests):
if isinstance(tests, TestSuite):
for child in tests:
print # package.module.TestClass.test_name