Skip to content

Instantly share code, notes, and snippets.

View jonsherrard's full-sized avatar
💭
Working

Jon Sherrard jonsherrard

💭
Working
View GitHub Profile
@jonsherrard
jonsherrard / query.js
Created September 21, 2012 15:11
query.js
function rad2deg (angle) {
return angle * 57.29577951308232; // angle / Math.PI * 180
}
function deg2rad (angle) {
return angle * .017453292519943295; // (angle / 180) * Math.PI;
}
function get_events (input_lat, input_lon) {
lat = input_lat;
@jonsherrard
jonsherrard / active_game.php
Created October 8, 2012 14:46
active_game.php
$this->facebook_id = $facebook_id;
$active_game = array_filter($games, function($game) {
return $game->active;
});
if (count($active_game) > 1):
$active_game = array_filter($active_game, function($game) {return $game->creator === $this->facebook_id;});
endif;
if (count($active_game)) $active_game[0]->garments = $this->get_garments($active_game[0]->game_id);
return $active_game[0];
@jonsherrard
jonsherrard / active_game.php
Created October 8, 2012 15:08 — forked from benhartley/active_game.php
active_game.php
<?
$this->facebook_id = $facebook_id;
$active_game = array_filter($games, function($game) {
return $game->active;
});
/*
# Not sure this is needed, the game with the lowest game_id should be returned.
if (count($active_game) > 1):
@jonsherrard
jonsherrard / active_game.php
Created October 8, 2012 15:11 — forked from benhartley/active_game.php
active_game.php
<?
$this->facebook_id = $facebook_id;
$active_game = array_filter($games, function($game) {
return $game->active;
});
/*
# Not sure this is needed, the game with the lowest game_id should be returned.
if (count($active_game) > 1):
@jonsherrard
jonsherrard / probs.php
Created November 27, 2012 13:14
idorm stuff
<?php
public function getAllPrizes() {
return ORM::forTable("prizes")->findMany();
}
var_dump(
$db->getAllPrizes()[0]->as_array()
);
@jonsherrard
jonsherrard / vimflowy.js
Last active December 13, 2015 21:18
A Userscript compatible version of VimFlowy plugin for Workflowy - https://github.com/thricedotted/vimflowy
function enterNormalMode() {
console.log("entering normal mode");
$(".editor > textarea").bind("keydown", blockAll);
$(".editor > textarea").addModalKeyboardShortcuts(normalKeybindings, insertKeybindings)
}
function enterInsertMode(e) {
e.preventDefault();
console.log("entering insert mode");
$(".editor > textarea").unbind("keydown", blockAll);
$(".editor > textarea").addModalKeyboardShortcuts(insertKeybindings, normalKeybindings)
@jonsherrard
jonsherrard / gotchas.md
Created February 23, 2013 13:59
Common JS gotchas

Common JavaScript "Gotchas"

Introduction:

JavaScript has a lot of weird behaviours that trip up noobs to the language - especially those acquainted with more traditional OOP languages. Hopefully this guide will provide a quickly scannable, easily understood list to save a lot of pain to those getting acquainted with the language.

Author:
Steve Kwan, Project Lead, EASPORTS.com
Electronic Arts

(function(e,t){function A(e){if(i==="")return e;e=e.charAt(0).toUpperCase()+e.substr(1);return i+e}var n=Math,r=t.createElement("div").style,i=function(){var e="t,webkitT,MozT,msT,OT".split(","),t,n=0,i=e.length;for(;n<i;n++){t=e[n]+"ransform";if(t in r){return e[n].substr(0,e[n].length-1)}}return false}(),s=i?"-"+i.toLowerCase()+"-":"",o=A("transform"),u=A("transitionProperty"),a=A("transitionDuration"),f=A("transformOrigin"),l=A("transitionTimingFunction"),c=A("transitionDelay"),h=/android/gi.test(navigator.appVersion),p=/iphone|ipad/gi.test(navigator.appVersion),d=/hp-tablet/gi.test(navigator.appVersion),v=A("perspective")in r,m="ontouchstart"in e&&!d,g=i!==false,y=A("transition")in r,b="onorientationchange"in e?"orientationchange":"resize",w=m?"touchstart":"mousedown",E=m?"touchmove":"mousemove",S=m?"touchend":"mouseup",x=m?"touchcancel":"mouseup",T=function(){if(i===false)return false;var e={"":"transitionend",webkit:"webkitTransitionEnd",Moz:"transitionend",O:"otransitionend",ms:"MSTransitionEnd"};retur
@jonsherrard
jonsherrard / find.sh
Created April 12, 2013 16:25
Find large files
du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1f\t%s\t%25s %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'
@jonsherrard
jonsherrard / static.js
Last active August 29, 2015 13:57 — forked from appleton/static.js
app.use(function(req, res, next) {
if(req.url.indexOf("js/") === 0) {
res.setHeader("Cache-Control", "public, max-age=345600");
}
if(req.url.indexOf("js/") === 0) {
res.setHeader("Cache-Control", "public, max-age=172800");
}
return next();
});
app.use(express.static(path.join(__dirname, 'www')));