Skip to content

Instantly share code, notes, and snippets.

@neckro
neckro / state.js
Created September 19, 2013 20:02
state-based event handler helper
// State machine, for event handlers and other mischief
define([], function() { "use strict";
///////////////////////
var stateM = {
create: function(target, config) {
var instance = Object.create(stateM.proto);
instance.statesHash = {};
instance.statesStack = [];
instance.begunStates = {};
instance.listeners = [];
@neckro
neckro / md.php
Created August 29, 2013 19:25
Quick and dirty PHP script to convert Markdown to HTML for web display
<?php
$file = realpath(@$_GET['f']);
$p = pathinfo($file);
if (!$file || strtolower(@$p['extension']) !== 'md') {
http_response_code(403);
exit;
}
$cmd = sprintf(
'./md/peg-multimarkdown/multimarkdown "%s" --smart | sed "s/\&#8211\;/\&mdash\;/g"',
escapeshellcmd($file)
@neckro
neckro / zalgo.py
Last active July 4, 2016 20:49
H͙̻͍ḙ̰ c͟͡o͕̳̻ͅm͍͚͈e̅s
#!/usr/bin/env python
from random import randint
from fileinput import input
from argparse import ArgumentParser
from sys import stdout
# "data set of leet unicode chars" stolen from
# Tchouky's Zalgo Generator on eeemo.net
@neckro
neckro / gist:5631488
Created May 22, 2013 22:34
Quickie key/value store page with PHP/MySQL, example
<?php
/* Table schema
CREATE TABLE `params` (
`key` varchar(255) NOT NULL DEFAULT '',
`value` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
*/
// Settings
@neckro
neckro / lpd8806_chasers.ino
Created September 6, 2012 02:06
LED chasers with LPD8806 controller
// uses https://github.com/neckro/LPD8806
#include "LPD8806.h"
#include "SPI.h"
// strip settings
const uint16_t PIXEL_LENGTH = 32;
// tracer settings
#define NUM_TRACERS 4
const int16_t MIN_POSRATE = 2;