Skip to content

Instantly share code, notes, and snippets.

@barahilia
barahilia / yield-profiling.md
Created January 6, 2016 08:19
Yield profiling

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
barahilia / points-compression.md
Last active August 29, 2015 14:07
Points compression algo
@barahilia
barahilia / highlight.md
Created October 12, 2014 19:01
Kramdown yellow highlight
Fill details here...
@barahilia
barahilia / workaround.js
Created September 9, 2014 13:27
Workaround for R# complaining on use of an implicitly declared global variable
// 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
barahilia / tdd-trees-comp-c++
Last active August 29, 2015 14:05
TDD for trees comparison in C++
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
@barahilia
barahilia / json-pattern-matcher
Last active August 29, 2015 14:04
JSON pattern matching
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
);
@barahilia
barahilia / run-jasmine.js
Last active March 24, 2022 11:38 — forked from dlidstrom/run-jasmine.js
Runs Jasmine tests using PhantomJS. Adapted for use within TeamCity..Compatible with Jasmine 2.0.
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.