Skip to content

Instantly share code, notes, and snippets.

View kirbysayshi's full-sized avatar

Drew Petersen kirbysayshi

View GitHub Profile
@kirbysayshi
kirbysayshi / LICENSE
Last active March 19, 2024 07:25
Hierarchical Spatial Hash Grid: extremely efficient spatial hashing for collision detection between objects of any size! This is an implementation in JS as described in http://www10.informatik.uni-erlangen.de/~schornbaum/hierarchical_hash_grids.pdf
Copyright 2012 Andrew Petersen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR O
@kirbysayshi
kirbysayshi / README.md
Created August 24, 2012 22:16
JS Module Guards

This Is Absolutely Tiring

Every time I start a node module, or a new JS project, I'm confronted with this same question: how do I structure it to allow it to be used in the browser or nodejs, without requiring a build step, and without getting in the way of my development?

While developing, I typically create some type of [browser-based environment][]; Firebug and Web Inspector are still miles ahead of anything else we've got. Ideally I want to be able to add a file via a script tag, and have that be the only requirement.

As @visionmedia [points out][], this is [ridiculous][].

This gist is meant to compile all of the various ways I've seen of guarding against/for a variety of module systems. Fork it and add your own, I'll try to bring them into this one.

@kirbysayshi
kirbysayshi / clean.sh
Created May 12, 2022 19:43
process profiling with graphs (bash, gnuplot)
for log in *-anary.log; do awk '$0<200' <$log | gnuplot -e "set term png; set yrange [0:200]; unset autoscale y; set output \"$(basename $log .log).trimmed.png\";plot '-' with boxes"; done
// From http://baagoe.com/en/RandomMusings/javascript/
function Alea() {
return (function(args) {
// Johannes Baagøe <baagoe@baagoe.com>, 2010
var s0 = 0;
var s1 = 0;
var s2 = 0;
var c = 1;
if (args.length == 0) {
@kirbysayshi
kirbysayshi / example.js
Created October 18, 2011 21:46
Very Simple Signals
var s = new Signal(), cb = function(a, b){ console.log('callback', arguments, this); };
s.add(cb);
s.add(cb);
s.dispatch('for', 'science', '!', 1);
s.remove(cb);
s.dispatch('for', 'science', '!', 2);
s.remove(cb);
s.dispatch('for', 'science', '!', 3);
@kirbysayshi
kirbysayshi / mass-aggregation-change.sh
Created November 23, 2011 17:14
quick examples of how to change many many wsp (graphite/whisper) files settings
for f in $(find $1 -iname "*.wsp"); do
if [ -a $f ];
then /opt/graphite/bin/whisper-set-aggregation-method.py $f max;
fi;
done
[
{
"name": "SofleKeyboard",
"author": "Josef Adamcik (+Drew Petersen)",
"switchMount": "cherry"
},
[
{
"x": 6.25,
"p": "CHICKLET"
/*
* def.js: Simple Ruby-style inheritance for JavaScript
*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(global) {
// used to defer setup of superclass and plugins
var deferred;
@kirbysayshi
kirbysayshi / _README.md
Last active October 28, 2020 21:51
use hdl_dump to inject local ISO/bin+cue files into a locally-connected Playstation 2 hard drive

Mac Instructions:

# clone the hdl-dump repo
USE_THREADED_IIN=no RELEASE=yes make # otherwise will semaphore deadlock

diskutil list # find the /dev/diskX identifier of the PS2 HDD

sudo -s # must be root to query drive and inject
IMG_ROOT=/path/to/ISOs HDD_IDENT=/dev/diskX CLI_PATH=./hdl_dump node ./mass_inject.js
@kirbysayshi
kirbysayshi / bash-to-zsh-history.js
Created August 12, 2020 23:09
port bash_history to zsh, while preserving existing zsh history too!
const fs = require('fs');
/**
* This script transfers bash history to zsh history
* Change bash and zsh history files, if you don't use defaults
*
* Usage: node bash_to_zsh_history.js
*
* Author: Matteo Gaggiano, Modified by Drew Petersen
*/