Skip to content

Instantly share code, notes, and snippets.

View dydx's full-sized avatar
🎯
Focusing

Josh Sandlin dydx

🎯
Focusing
View GitHub Profile
@dydx
dydx / mongod-down
Created December 2, 2014 22:56
management scripts for MongoDB on ChromeOS
#!/bin/bash
echo "Terminating mongodb..."
kill $(pgrep mongod)
@dydx
dydx / xor_cipher.js
Created January 6, 2015 03:35
fuckin with some xor stuff in javascript
function cipher(message, key) {
return message.split('')
.map(function(element) {
return (element.charCodeAt(0) ^ key);
})
.map(function(element) {
return String.fromCharCode(element)
})
.join('');
}
@dydx
dydx / httpserver.io
Created January 12, 2015 06:26
http server with something resembling a templating language for 'dynamic' content
Iota := Object clone do (
stack := nil
output := nil
init := method (
stack = List clone
output = List clone
)
squareBrackets := method (
@dydx
dydx / shittydb.py
Created January 23, 2015 07:00
#wow so fast
import subprocess
def set(key, val):
f = open(key, 'w')
f.write(val)
f.close()
def get(key):
return subprocess.check_output(["cat", key])
@dydx
dydx / dumb_bloom.js
Last active August 29, 2015 14:15
dumb bloom filter based on a single hash function that adds up the ASCII of a given key string.
module.exports = {
bitArray: Array.apply(null, new Array(100)).map(Number.prototype.valueOf, 0),
hash: function(key) {
return key.split('')
.map(function(element) {
return element.charCodeAt(0);
})
.reduce(function(a, b) {
return a + b;
});

Keybase proof

I hereby claim:

  • I am dydx on github.
  • I am jpsandlin (https://keybase.io/jpsandlin) on keybase.
  • I have a public key whose fingerprint is FDE4 98CC 0023 D84D 4FB0 4A57 2409 F26A BD50 5DEF

To claim this, I am signing this object:

// so this is a thing that was successfully used to "fix" a headers race condition in an Express app.
// Jesus christ this is stupid
function(req, res, next) {
var originalSend = res.send
res.send = function() {
if (this.headersSent()) return
originalSend.apply(this, arguments)
}
}
@dydx
dydx / index.php
Created March 22, 2015 02:18
playing with the treehouse thing on autoloading
<?php
@dydx
dydx / gist:9c606a58be795f171508
Created March 25, 2015 06:34
work-handler-snippet
$(document).ready(function() {
$.getJSON('http://192.168.3.193:8000/api/all', function(data) {
data.forEach(function(data) {
console.log(data);
$("#work-list").append(
"<li><a href='/admin/work-order.html#"+data._id+"'>"+data.properties.name+"</a></li>"
);
})
})
});
@dydx
dydx / gist:5bca7ef7b66b74dbffca
Created March 25, 2015 06:36
pass database entry id through window.location.hash
var work_order_id = $(location).attr('hash').substring(1);
$.getJSON('http://192.168.3.193:8000/api/' + work_order_id, function(data) {
$('#work-info').append(
'<li style="text-decoration: none;">' + JSON.stringify(data[0].properties.name) + '</li>'
)
$('#map').attr('src', '/admin/map-test.html#' + work_order_id);
});