Skip to content

Instantly share code, notes, and snippets.

View diegocstn's full-sized avatar

Diego Costantino diegocstn

View GitHub Profile
@diegocstn
diegocstn / sum.js
Created March 12, 2017 17:44
add two numbers without using arithmetic operators
function add(x, y) {
while (y != 0) {
const carry = x & y;
x = x ^ y;
y = carry << 1;
}
return x;
}

Keybase proof

I hereby claim:

  • I am diegocstn on github.
  • I am diegocostantino (https://keybase.io/diegocostantino) on keybase.
  • I have a public key whose fingerprint is DB50 CB48 8F0D AD9D C572 C4E7 0249 A469 0F74 C7A3

To claim this, I am signing this object:

@diegocstn
diegocstn / gist:305f843211c62bb5c1d5
Created July 1, 2014 22:41
JavaScript delegate
app.delegate = function(obj,fn){
return (function(obj,fn,arg){
return function(){ fn.apply(obj, arg);};
})(obj,fn,Array.prototype.slice.call(arguments,2));
};
@diegocstn
diegocstn / gist:6701712
Created September 25, 2013 15:52
Open Safari Mobile on iOS simulator passing a url with command line ( DRAFT )
#!/usr/bin/env ruby
basePath = "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/"
simulatorPath = basePath + "Applications/iPhone\\ Simulator.app/Contents/MacOS/iPhone\\ Simulator -SimulateApplication"
sdkPath = basePath + "SDKs/"
safariPath = "Applications/MobileSafari.app/MobileSafari"
# check arguments
if ARGV.count > 3 || ARGV.count < 1
puts "Usage: safarimob url [--sdk 6.1|7.0 ]"