Skip to content

Instantly share code, notes, and snippets.

@mjhoy
mjhoy / problem.js
Created March 24, 2014 11:42
js: new is problematic
function K() {
this.za = "ze";
};
console.log(new K()); // => K { za: "ze" }
K.D = function() {
this.la = "le";
};

Keybase proof

I hereby claim:

  • I am mjhoy on github.
  • I am mjhoy (https://keybase.io/mjhoy) on keybase.
  • I have a public key whose fingerprint is FBB6 73D7 2A0F E808 FDBC DFC2 F711 D0A2 4C69 F1DB

To claim this, I am signing this object:

@mjhoy
mjhoy / etags-drupal.sh
Created November 21, 2014 20:15
running etags for drupal
# so i remember, from this page: http://www.emacswiki.org/PhpMode
etags --language=php `find . -name "*.php" -or -name "*.inc" -or -name "*.module" -or -name "*.theme" -or -name \
"*.engine" -or -name "*.ini"` --language=JavaScript `find . -name "*.js" -and -not -name "*.min.js" -and -not -name \
"*.pack.js" -and -not -name "*_pack.js" -and -not -name "*_stripped.js" -and -not -name "*_mini.js" -and -not -name \
"swfobject.js" -and -not -name "cal.js" -and -not -path "*/tinymce/jscripts/*" -and -not -name "ext-*.js" -and -not -path \
"*/files/*" -and -not -path "*/editors/jce/*" -and -not -path "*/libraries/*" -and -not -path \
"*/modules/ckeditor/ckeditor/*" -and -not -path "*/modules/fckeditor/fckeditor/*" -and -not \
-path "*/com_virtuemart/js/*" -and -not -path "*/media/system/js/*" -and -not -path "misc/jquery.js"`
@mjhoy
mjhoy / output 2
Last active August 29, 2015 14:25
nix output
$ nix-env -iA nixpkgs.haskell-ng.packages.ghc7101
[.....lots of "installing" lines....]
installing ‘haskell-zoneinfo-0.5’
installing ‘haskell-zoom-0.1.0.1’
installing ‘haskell-zoom-cache-1.2.1.6’
installing ‘haskell-zoom-cache-pcm-0.3.0.1’
installing ‘zoom-cache-sndfile-1.1.0.1’
installing ‘zot-0.0.2’
@mjhoy
mjhoy / output
Created October 13, 2015 20:11
nix-shell output
shell.nix:
with (import <nixpkgs> {}).pkgs.haskellPackages;
{
xml-conduit = xml-conduit;
}
[mjhoy@mjh-air-2 xlsx-parse]$ nix-shell --dry-run
these derivations will be built:
/nix/store/zv7blfiwizipj8p519dmnpslp0lcll7i-perl-5.20.2.drv
@mjhoy
mjhoy / nix-out.txt
Created November 3, 2015 02:30
nix output
$ nix-env -e hello -vvv
adding path ‘/Users/mjhoy/.nix-defexpr/channels/nixpkgs’ to the search path
adding path ‘/Users/mjhoy/.nix-defexpr/channels/nixpkgs’ to the search path
adding path ‘/nix/store/1rn8whr57nnkcfaqf3v0d741prfcd8ky-nix-1.10/share/nix/corepkgs’ to the search path
evaluating file ‘/nix/store/1rn8whr57nnkcfaqf3v0d741prfcd8ky-nix-1.10/share/nix/corepkgs/derivation.nix’
evaluating file ‘/nix/store/9hi7j0a2ii2svzvbfc4iq0ybzyp4s25z-env-manifest.nix’
evaluating list element
evaluating list element
evaluating list element
#!/bin/bash
# Commit changes to ~/Dropbox/org
set -e
cd /Users/mjhoy/Dropbox/org
if git status | grep 'working directory clean'
then exit
@mjhoy
mjhoy / if-bound.hs
Created November 11, 2015 18:47
if-bound
ifBound :: SnapletISplice b
ifBound = do
inp <- getParamNode
let t = X.getAttribute "tag" inp
case t of
Nothing -> return mempty
Just t' -> do
st <- getHS
let s = lookupSplice t' st
case s of
@mjhoy
mjhoy / README.md
Last active December 15, 2015 20:29
Visualizing Quicksort

There are three parts to quicksort. For an array, (1) choose a “pivot” item. Using the pivot, (2) partition the array around the pivot, such that the array to the left of the pivot is less than the pivot; the array to the right of the pivot is greater than the pivot. Finally, (3) invoke quicksort recursively on the left and right partitions.

Recursion can be tricky to understand. Using d3.js, we can represent each recursive call to quicksort as a node, whose parent is the array of which it is a partition, and whose children are its partitions. The base case is when the array is only one element — this is the state of the leaf nodes.

@mjhoy
mjhoy / README.md
Last active December 15, 2015 21:39
Adventure viewer

A little previewer for a text-based adventure game.

It will render a directed graph for you, using d3.js and [d3.layouts.force][force]. The arrows (showing directed edges) were a little tricky. They are rendered given source and target coordinates with some basic trigonometry:

arrow.attr("transform", function(d) {
    var p1  = [d.source.x,d.source.y],