Skip to content

Instantly share code, notes, and snippets.

View jbt's full-sized avatar

James Taylor jbt

View GitHub Profile
@jbt
jbt / livecat.js
Created April 1, 2016 08:46
GoSquared Embedded Live Cat
function embedLiveCatTM() {
var 📄 = document, 💅 = "style", ⬅ = "left", ⬇ = "bottom", 👍 = "translateX(-50%)", 🐳 = window,
↕ = "innerHeight", ↔ = "innerWidth", 😺 = 0, 🐈 = 🐳[↔] / 2, 🖖 = 0, 🎺 = 0, 👻 = "px",
🔢 = Math, ⏲ = setInterval, 💩, 🐱 = 📄.createElement("img");
🐱.setAttribute("src", "//static.gosquared.com/images/april/nes/cat_02.png");
🐱[💅].height = 🐳[↕] / 20 * 10 + 👻;
🐱[💅].position = "fixed";
🐱[💅].transform = 👍;
📄.body.appendChild(🐱);
(function 🖌(){
@jbt
jbt / desk.coffee
Last active August 29, 2015 13:56
Desk.com hubot script
# hubot script for desk
module.exports = (robot) ->
robot.router.post "/hook/desk", (req, res) ->
body = req.body.data
lines = body.split "\n"
data = {}
lines.forEach (line) ->
bits = line.split ":"
data[bits.shift()] = bits.join ":"
@jbt
jbt / thing.js
Created April 6, 2013 12:47
Thought Exercise
// Without running this: what gets logged in what order?
var a = {};
Object.defineProperty(a, 'a', { get: function(){
console.log('get a');
return function(){ console.log('a'); return a; };
}});
Object.defineProperty(a, 'b', { get: function(){
@jbt
jbt / index.html
Last active December 14, 2015 15:29
Example use of GoSquared polymaps fork.
<!DOCTYPE html>
<html>
<head>
<title>Polymaps Example</title>
<script src="polymaps.min.js"></script><!-- polymaps from gosquared/polymaps -->
</head>
<body>
<svg id="map" width="1000" height="800"></svg>
@jbt
jbt / gist:5055782
Last active December 14, 2015 08:08
Super-tiny recursive directory list in nodejs, if you don't care that you're using sync functions.
var fs = require('fs');
function ls(dirname){
return [].concat.apply([], fs.readdirSync(dirname).sort().map(function(f){
f = dirname + '/' + f
return fs.statSync(f).isDirectory() ? ls(f) : f
}));
}
@jbt
jbt / gist:3847944
Created October 7, 2012 11:26
Think I broke node.
"res[860] = /(?:[\\040\\t]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff])*\\))*\\))*(?:(?:[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff])|\"(?:[^\\\\\\x80-\\xff\\n\\015\"]|\\\\[^\\x80-\\xff])*\")(?:(?:[\\040\\t]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff])*\\))*\\))*\\.(?:[\\040\\t]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff])*\\))*\\))*(?:[^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff]+(?![^(\\040)<>@,;:\".\\\\\\[\\]\\000-\\037\\x80-\\xff])|\"(?:[^\\\\\\x80-\\xff\\n\\015\"]|\\\\[^\\x80-\\xff])*\"))*(?:[\\040\\t]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff])*\\))*\\))*@(?:[\\040\\t]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff]|\\((?:[^\\\\\\x80-\\xff\\n\\015()]|\\\\[^\\x80-\\xff])*\\))*\\)
@jbt
jbt / hello.js
Created September 7, 2012 20:54
Just found this, called blah.js, in my ~/Development
alert("
@jbt
jbt / gist:3150819
Created July 20, 2012 13:47
If you can tell me what these two functions are for, you win a prize
t.prototype.REDACTED = function(a, b, j, c, g) {
for(var r = this.REDACTED2(0), t = Math.tan(r), C = g % 86400 / 86400 * Math.PI * 2, g = [], n = 0;n <= c + 1;n = n + 1) {
g[n] = Math.atan(Math.cos(2 * Math.PI * (j + n / c) / a + C) / t) / Math.PI * c * a / 2 - (b - a / 4) * c;
}
b = Math.max.apply(Math, g);
j = Math.min.apply(Math, g);
a = "";
if(g[0] > 0 && g[0] < c) {
a = "M0," + g[0];
if(b >= c) {
@jbt
jbt / gist:3112153
Created July 14, 2012 17:08
Comparator function
/*
Ridiculously useful function
Sorts elements of an array by properties
Usage:
Sort elements by property prop1, then by prop2 if prop1 values are equal
someArrayOfObjects.sort(comparator('prop1', 'prop2'));
*/
function comparator(){
@jbt
jbt / gist:2419469
Created April 19, 2012 07:48
jQuery jsonp auto-generated callbacks memory leak.
<?php
// Only run this locally, unless you want to bombard your server with hundreds of requests a second.
if($_GET['a']) die( $_GET['callback'] . '(false);');
?>
<!DOCTYPE html>
<html>
<head>