Skip to content

Instantly share code, notes, and snippets.

View jeresig's full-sized avatar

John Resig jeresig

View GitHub Profile
#!/usr/bin/env ruby
$: << ENV['TM_SUPPORT_PATH'] + '/lib'
require 'escape'
def esc(str)
e_sn(str).gsub(/\}/, '\\}').gsub(/"/, '\\\\"')
end
s = STDIN.read
if ENV.has_key? 'TM_SELECTED_TEXT'
print "${1:{{ __(\"#{esc s}\") \\}\\}}"
function Vb(d) {
d = d | 0;
var e = 0, f = 0, h = 0, j = 0, k = 0, l = 0, m = 0, n = 0,
o = 0, p = 0, q = 0, r = 0, s = 0;
e = i;
i = i + 12 | 0;
f = e | 0;
h = d + 12 | 0;
j = c[h >> 2] | 0;
if ((j | 0) > 0) {
@jeresig
jeresig / frick.json
Last active February 15, 2016 22:05
Sample artwork metadata records for PHAROS Images.
{
"id": "b11104624",
"url": "http://arcade.nyarc.org/record=b1110462~S7",
"lang": "en",
"title": "S. John the Baptist Enthroned and Twelve Scenes from His Life.",
"dates": [
{
"start": 1200,
"end": 1299,
"circa": false
@jeresig
jeresig / block-puzzle.js
Created December 27, 2016 21:15
Super-hacky solver for the "Gopher Holes" puzzle: http://amzn.to/2hqLO2V
/**
* Super-hacky solver for the "Gopher Holes" puzzle:
* http://amzn.to/2hqLO2V
*
* Note: I assumed that the blocks would be going vertically in one direction
* and horizontally in another.
*
* Also: I wrote this for fun over the holidays - I'm sure this code is
* terrible and could be improved. It was good enough for my needs!
*
tap.test("RecordImport.advance", (t) => {
const checkStates = (batches, states) => {
t.equal(batches.length, states.length);
for (const batch of batches) {
t.equal(batch.state, states.shift());
t.ok(batch.getCurState().name(i18n));
}
};
const batch = init.getRecordBatch();
@jeresig
jeresig / output.txt
Last active September 5, 2017 10:43
worker-nodes big data transfer performance
$ node test_server.js
simple: 337.425ms
simple2: 1.971ms
big data: 3385.748ms
big data stringify: 801.013ms
big string: 565.437ms
# Rename an email address in all old commits.
# WARNING: Will change all your commit SHA1s.
# Based off of the script from here:
# http://coffee.geek.nz/how-change-author-git.html
git filter-branch -f --commit-filter '
if [ "$GIT_COMMITTER_EMAIL" = "joern.zaefferer@googlemail.com" ];
then
GIT_AUTHOR_EMAIL="joern.zaefferer@gmail.com";
GIT_COMMITTER_EMAIL="joern.zaefferer@gmail.com";
git commit-tree "$@";
@jeresig
jeresig / .vimrc
Created May 4, 2011 16:46
VIM Config
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
set nocompatible
set autoindent
set tabstop=2
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
syntax on
// Slightly rewritten code from here:
// http://blog.mozilla.com/webdev/2009/08/06/html5-audio-soundboard/
$("audio").removeAttr("controls").each(function(i, audio) {
$('<button>')
.text( $(this).attr("title") )
.click(function() {
audio.play();
))
.appendTo("#doc");
});
@jeresig
jeresig / cookiebot.js
Last active October 5, 2023 12:20
Simple bot for CookieClicker: http://orteil.dashnet.org/cookieclicker/ How to use: Paste the following into the JavaScript console in your browser and run it. To start the bot type: "CookieClicker.start();" to stop it do: "CookieClicker.stop();" (or just reload the page).
CookieClicker = {
start: function() {
this.clickInterval = setInterval(function(){
// Click the large cookie as fast as possible!
document.getElementById("bigCookie").click();
}, 1);
this.goldInterval = setInterval(function(){
// Click the golden cookie
var shimmer = document.getElementsByClassName("shimmer")[0];