Skip to content

Instantly share code, notes, and snippets.

@gilomen2
gilomen2 / gist:e7186b40e997e01b9f2f78fe0f007c68
Last active April 14, 2017 15:35
Current configuration
import './snowplow-distro';
if (!window['onespot_tracker']) {
window.GlobalSnowplowNamespace = window.GlobalSnowplowNamespace || [];
window.GlobalSnowplowNamespace.push('onespot_tracker');
window['onespot_tracker'] = function() { (window['onespot_tracker'].q = window['onespot_tracker'].q || []).push(arguments); };
window['onespot_tracker'].q = window['onespot_tracker'].q || [];
}
window.onespot_tracker('newTracker', 'client-javascript', 'sp.os-data.com', { // Initialise a tracker
// NOPE
String.prototype.padLeft = function(ch, n) {
var newString = this;
while(newString.length < n){
newString = ch + newString;
}
if(typeOf(ch) === "string"){
return newString;
function _if(bool, func1, func2) {
if(bool === true){
return func1();
} else {
return func2();
}
};
//Test
Test.assertEquals(_if(true, function(){console.log("True")}, function(){console.log("false")}), 'True')
@gilomen2
gilomen2 / truthiness.rb
Created September 10, 2015 21:01
Unexpected true/false behavior using defined?
THING = "thing_one"
puts THING
if defined? THING
puts "defined? THING is truthy"
else
puts "defined? THING is falsey"
end
@gilomen2
gilomen2 / result
Last active August 29, 2015 14:24
Benchmark binary search vs. iterative search
user system total real
Binary - Bill: 0.000000 0.000000 0.000000 ( 0.000014)
Iterative - Bill: 0.000000 0.000000 0.000000 ( 0.000012)
Binary - Bob: 0.000000 0.000000 0.000000 ( 0.000020)
Iterative - Bob: 0.000000 0.000000 0.000000 ( 0.000007)
Binary - Joe: 0.000000 0.000000 0.000000 ( 0.000005)
Iterative - Joe: 0.000000 0.000000 0.000000 ( 0.000005)
Binary - Sally: 0.000000 0.000000 0.000000 ( 0.000007)
Iterative - Sally: 0.000000 0.000000 0.000000 ( 0.000005)
Binary - Sussie: 0.000000 0.000000 0.000000 ( 0.000007)