Skip to content

Instantly share code, notes, and snippets.

from decimal import Decimal
for i in range(1, 1000000):
x = Decimal(i)
y = Decimal(i + 1)
z = x / y
### Keybase proof
I hereby claim:
* I am xcoderzach on github.
* I am zachs (https://keybase.io/zachs) on keybase.
* I have a public key whose fingerprint is 8867 97BD B083 6399 3A27 10BF BC77 1768 26E3 1682
To claim this, I am signing this object:
### Keybase proof
I hereby claim:
* I am xcoderzach on github.
* I am zachs (https://keybase.io/zachs) on keybase.
* I have a public key whose fingerprint is F5FC 7CF2 538F FF50 DB0F D6CA 7166 7314 0CB9 EC15
To claim this, I am signing this object:
@xcoderzach
xcoderzach / function_bind_syntax.js
Last active August 29, 2015 14:15
Function Bind Syntax
import _ from 'lodash'
function ooify(fn) {
return function() {
return fn.apply(this, [this].concat([].slice.call(arguments)))
}
}
var methods = _.zipObject(_.map(_.keys(_.prototype), methodName => {
return [methodName, ooify(_[methodName])]
}))
window.oldWS = window.WebSocket
window.sockets = []
window.WebSocket = function() {
var ws = oldWS.apply(this, arguments);
window.sockets.push(ws);
return ws;
}
@xcoderzach
xcoderzach / acos
Created October 8, 2014 20:52
like acos, except returns degrees, a domain of -Infinity to Infinity, and a range of 0 to 360
function f(x) {
x = ((((x + 2) % 4) + 4) % 4) - 2
if(x > 1) return 360 - Math.acos(2 - x) * (180/Math.PI)
if(x < -1) return 360 - Math.acos(-2 - x) * (180/Math.PI)
return Math.acos(x) * (180/Math.PI)
}
var exec = require('child_process').exec
var browsers = { chrome: 'Google\\ Chrome.app', firefox: 'Firefox.app', safari: 'Safari.app' }
function openInBrowser(browser) {
exec("open -a " + browsers[browser])
}
openInBrowser('safari')
while true
do
dig google.com
sleep 240
done
@xcoderzach
xcoderzach / gist:26cf445e055fbd490e5b
Created July 21, 2014 20:11
simulated scrolling that bounces once it reaches the edge, and damps if you pull it outside the boundry.
var boundry = Physics.Boundry(0, 0, height, width)
var draggable = drag({ boundryDamping: .2 }).bounds(boundry)
var decelerate = phys.decelerate({ deceleration: 1000 }).bounds(boundry).start
var spring = phys.spring({ deceleration: 1000 }).start
draggable.pipe(phys)
draggable.start()
.then(decelerate)
.then(spring)
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
console.log('onDeviceReady()');
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, function() { console.log('FAIL - window.requestFileSystem'); } );
}
// var mediaEncoded;
function gotFS (fileSystem) {
console.log("GotFS()");