View gist:0fb5825c4268b988166e
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local verb, resource, version, headers, body = data:match("(.+)%s+(.+)%s+(HTTP/%d%.?%d?)\r\n(.-)\r\n\r\n(.-)") | |
headers:gsub("(.-)%s*:%s*(.-)\r\n", function(name, value) | |
-- do something with name and value here | |
end) |
View gist:67c719b8597a837d59fd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
import java.util.Comparator; | |
import java.util.Collections; | |
int index = 0; | |
PImage pokemon, current; | |
PGraphics pie; | |
HashMap<Integer,Integer> colorMap; | |
ArrayList<Integer> colorByCount; |
View PokéPie
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Map; | |
import java.util.Comparator; | |
import java.util.Collections; | |
int index = 0; | |
// sprite sheet | |
PImage pokemon; | |
// current pokemon sprite | |
PImage current; | |
// current pie chart |
View send_sms_get_example.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// just for the record | |
$phone_ip = "10.0.0.2"; | |
$phone_port = 8080; | |
$phone_page = "/send"; | |
// to be clear, this is set in the app preferences | |
// you can turn off password protection, but i wouldn't suggest it | |
$tinysmsgate_password = "password"; | |
View name.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function name (id, l) { | |
function n(){return id=(399*id)%509} | |
var r="BDGKNPTVZ"[n()%9] | |
for (var i=1;i<l;i++) r+=i%2?"aeiou"[n()%5]:"bdgknptvz"[n()%9] | |
return r | |
}; | |
// id=seed, l=length | |
function name (id, l) { | |
// lcg prng |
View shuffle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function shuffle(set){ | |
for (var c=set.slice(0),o=[],m=Math; c.length > 0; o.push(c.splice(m.floor(m.random() * c.length), 1)[0])); | |
return o; | |
} | |
with (Math) | |
for ( | |
// c becomes shallow copy of array | |
// o is output | |
var c=set.slice(0),o=[]; |
View lcg.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var LCG = (function () { | |
var c = 0x93456789, a = 0x169659, mod, mask, r; | |
mask = (mod = Math.pow(2, 31)) - 1; | |
function LCG(seed) { | |
this.seed = seed || new Date().getTime(); | |
} | |
LCG.prototype = { | |
nextInt: |
View example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var template = "{?condition}Condition exists! {condition}{/condition}\n\n" + | |
"{^whereami}I am not here!{/whereami}\n\n" + | |
"{#list}{name} is {age} years old! {?old}They are *old*!{/old}{!old}They are not old!{/old}\n{/list}"; | |
console.log(stache(template, { | |
condition: "Hello world!", | |
list: [ | |
{name: "Charles", age: "25"}, | |
{name: "Bob", age: "42", old: true}, | |
{name: "Samantha", age: "32"}, |
View ago.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ago(elapsed): | |
o = [] | |
for unit, size in [("yr",365*24*60*60),("mo",30*24*60*60),("wk",7*24*60*60),("d",24*60*60),("hr",60*60),("min",60),("sec",1)]: | |
if size > elapsed: continue | |
total = int(elapsed / size) | |
elapsed = elapsed % size | |
o.append(str(total) + unit) |
View display.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only semi-golfed, mostly because i was in the headspace; only used for debugging | |
var w, h, x, y, m=maze(w=16,h=16), g=[]; | |
// generate fully walled grid | |
for(y = 0; y < h * 2 + 1; y ++) { | |
g[y]=[] | |
for(x = 0; x < w * 2 + 1; x ++) | |
g[y].push(!(y&1)?"#":!(x&1)?"#":" "); | |
} |
OlderNewer