Skip to content

Instantly share code, notes, and snippets.

@ansuz
ansuz / gist:a7c8737c76aeab5e4295
Created January 12, 2016 15:49
hijack handlers from prototype js
var registerFirst = function (elem, evt, handler) {
var x=0;
Event.cache[elem._prototypeUID][evt].map(function (x) {
elem.stopObserving(evt, x.handler);
return x.handler;
}).map(function (h) {
if (!x++) {
elem.observe(evt, handler);
}
elem.observe(evt, h);
@ansuz
ansuz / parseURL.js
Last active August 29, 2015 14:24
parseURL.js
/*
parseURL can optionally take a string, and return a parsed object
otherwise, pass it nothing and it will initialize itself from location.href
*/
function parseURL(url){
url=typeof url === 'string'?{full:url}:{full:location.href};
// url.extended is an array /first/second/third/fourth
url.extended=url.full
.replace(/#.*/,function(h){
// pull out the hash, if it exists
@ansuz
ansuz / keybase.md
Created December 15, 2014 01:19
I'm ansuz

Keybase proof

I hereby claim:

  • I am ansuz on github.
  • I am ansuz (https://keybase.io/ansuz) on keybase.
  • I have a public key whose fingerprint is 0F02 923D 982A 4ACD 50C3 A036 024A 7C03 E67E D8CF

To claim this, I am signing this object:

@ansuz
ansuz / editor.html
Last active August 29, 2015 14:08
a dual mode html5 app which displays either rendered markdown or the generated html
<!DOCTYPE html>
<html>
<head>
<title>Single Page Markdown Editor</title>
<body>
<input type="checkbox" id="mode"></input> :: Render as Markdown<br>
<textarea id="text-input" oninput="this.editor.update()" rows="6" cols="60">
Type **Markdown** here.
@ansuz
ansuz / dino.js
Created October 31, 2014 06:18
a dinosaur
var dino=function(){
return function(){/*
_
/ _)
.-^^^-/ /
__/ /
/__.|_|-|_|*/}.toString().split(14,-3);
};
@ansuz
ansuz / gist:b016d3ef929849c24254
Last active August 29, 2015 14:07
split a csv
var fs = require("fs");
var AA=[]; // variable outside of the function, in case you want it later
// will be an array of arrays, initialized so we can print it without undefined
fs.readFile("./pew.pew","utf8",function(err,data){ // read file pew.pew into memory
if(err)console.log(err); // tell us if there's a problem
else{
AA=data.split("\n") // split by line
.map(function(line){
var cent = function(n){
console.log("\
....\\...../\n\
.....╚⊙ ⊙╝");
while(n){
console.log("...╚═(███)═╝\n\
..╚═(███)═╝\n\
.╚═(███)═╝\n\
╚═(███)═╝\n\
╚═(███)═╝\n\
### Keybase proof
I hereby claim:
* I am ansuz on github.
* I am ansuz (https://keybase.io/ansuz) on keybase.
* I have a public key whose fingerprint is 9C8B C233 9042 B17E C6EF A4EE 81B4 60C5 02C7 7F4B
To claim this, I am signing this object: