Skip to content

Instantly share code, notes, and snippets.

View bortels's full-sized avatar

Tom Bortels bortels

  • Simi Valley, CA, USA
View GitHub Profile
@bortels
bortels / dkjson
Created March 25, 2012 22:40
json encode/decode in lua
--[==[
David Kolf's JSON module for Lua 5.1/5.2
========================================
*Version 2.1*
This module writes no global values, not even the module table.
Import it using
@bortels
bortels / jpeg2hex.pl
Created December 7, 2011 19:04
convert jpg to hex pnm
#!/usr/bin/perl
$f = shift @ARGV || die "syntax: jpg2hex FILENAME\n";
open($fh, "jpegtopnm tomfezicon.jpeg | pnmtoplainpnm |");
$x = <$fh>; print $x;
while (<$fh>) {
@r = split(/\s+/);
foreach $h (@r) { printf("%02x", $h); }
print "\n";
}
@bortels
bortels / tomfezicon.hex
Created December 7, 2011 00:03
tomfezicon.jpg in pnm format, hex
P3
4040
ff
0c1319263d43164148003138053039001522121b2c060719
0f0d1b13101918161b211e25282735111a2b2139450f3039
21192e29172d1d0b2115162809243500233f031d420a193a
0b16281620294851564b555736424201100d0911140d0d19
29222a0d0a1116171b111619060b0e090d10090d10090c11
1619201b1e2520232c1c1f281d202711191c0f191b162222
1a212b1e202c1d2029191d201c22222a2e313e41484d5256
@bortels
bortels / tomfezicon.b64
Created December 6, 2011 19:43
base 64 encoded tomfezicon.pnm
UDYKNjQgNjQKMjU1CgwTGSY9QxZBSAAxOAUwOQAVIhIbLAYHGQ8NGxMQGRgWGyEeJSgnNREaKyE5
RQ8wOSEZLikXLR0LIRUWKAkkNQAjPwMdQgoZOgsWKBYgKUhRVktVVzZCQgEQDQkRFA0NGSkiKg0K
ERYXGxEWGQYLDgkNEAkNEAkMERYZIBseJSAjLBwfKB0gJxEZHA8ZGxYiIhohKx4gLB0gKRkdIBwi
IiouMT5BSE1SVlBZWFVbW1xbYV1bYFpcWVVcVFVbV1VYXSQpLT1MUyA7RAosNQQlLgQYIw8WJgkI
GAsLFxsaIBUTGB0aIxQWIxAcKiI4RREuNikVLjEZMyEKJBobLwYhNAAjPQAeQQAZNwYZKhMhKkhS
W01UXDpCRQ0VFxERGRcOHygnLQ4NExYVGigpLQ0OEhIRFhIQFRAPFRodJAcOFAcQFwkQFgwRFxQX
HBgdIRcfIRkiKRkgKhkdJhwkJxgiIxYdIxkgKB4lKy02NUpQUFtaX19dYlNVVE1TT0lSUUlQWDtB
QUNITkJKVUFSWjlOUzdGTTA2QistOiMmLzg7QCsqLy0sNBMXIgQSHSk9SA8lMCkMKDYZNRwIIxcZ
LgciNwAlPgAlQgAeNQEYKBclME1VYE5SXjk8QxUWGxAKFhgJHhkeIg8QFRMRFiMeJBMRFhYRFxgR
GBgRGSsrMxMcIRQjJgsWGgcKEQwLERcWHBwgIxkkJhojKBskKRYhIxclJhsmKhskLRojKBUfID9I
@bortels
bortels / tom.uu
Created December 6, 2011 18:27
uuencoded pnm of tomfezicon
begin 644 tom.pnm
M4#8*-C0@-C0*,C4U"@P3&28]0Q9!2``Q.`4P.0`5(A(;+`8'&0\-&Q,0&1@6
M&R$>)2@G-1$:*R$Y10\P.2$9+BD7+1T+(146*`DD-0`C/P,=0@H9.@L6*!8@
M*4A15DM55S9"0@$0#0D1%`T-&2DB*@T*$187&Q$6&08+#@D-$`D-$`D,$189
M(!L>)2`C+!P?*!T@)Q$9'`\9&Q8B(AHA*QX@+!T@*1D=(!PB(BHN,3Y!2$U2
M5E!96%5;6UQ;85U;8%I<655<5%5;5U58720I+3U,4R`[1`HL-00E+@08(P\6
M)@D(&`L+%QL:(!43&!T:(Q06(Q`<*B(X11$N-BD5+C$9,R$*)!H;+P8A-``C
M/0`>00`9-P89*A,A*DA26TU47#I"10T5%Q$1&1<.'R@G+0X-$Q85&B@I+0T.
M$A(1%A(0%1`/%1H=)`<.%`<0%PD0%@P1%Q07'!@=(1<?(1DB*1D@*AD=)APD
M)Q@B(Q8=(QD@*!XE*RTV-4I04%M:7U]=8E-55$U33TE244E06#M!04-(3D)*
@bortels
bortels / Base64.lua
Created December 6, 2011 05:56
Base64 encode/decode for Codea (Lua)
-- Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss <alexthkloss@web.de>
-- licensed under the terms of the LGPL2
-- character table string
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
-- encoding
function enc(data)
return ((data:gsub('.', function(x)
local r,b='',x:byte()
@bortels
bortels / decodea.pl
Created December 2, 2011 07:57
Decode a .codea rtfd file
#!/usr/bin/perl
# Tom's nasty and ugly .codea (rtfd) decoder
# I release this bad boy to the public domain, you can't stop me!
$debug=1;
$f = shift @ARGV || "Font.codea";
open ($fh, $f);
@bortels
bortels / gist:1388116
Created November 23, 2011 07:34
Keyboard for Codea
Keyboard = class()
function Keyboard:init()
self.keyinfo = {
one = { chr="1", glyph="1", schr="!", sglyph="!", row=4, col=2 },
two = { chr="2", glyph="2", schr="@", sglyph="@", row=4, col=3 },
three = { chr="3", glyph="3", schr="#", sglyph="#", row=4, col=4 },
four = { chr="4", glyph="4", schr="$", sglyph="$", row=4, col=5 },
five = { chr="5", glyph="5", schr="%", sglyph="%", row=4, col=6 },
six= { chr="6", glyph="6", schr="^", sglyph="^", row=4, col=7 },
@bortels
bortels / convert.pl
Created November 22, 2011 17:43
convert font data for codify
#!/usr/bin/perl
# This is ugly - I disavow all knowledge of it's existence. It was a one-off, so there are NO
# attempts to make it clean or understandable. HERE THERE BE DRAGONS.
use MIME::Base64;
#font = {
# " " = { name="space", symbol=" ", width=16, ascii=32,
# data={} }
@bortels
bortels / starfield.js
Created November 7, 2011 06:06
Javascript Starfield
function StarField(canvas_id, width, height, num_stars) {
var width = width ? width : 3000,
height = height ? height : 1500,
origin_x = width / 2,
origin_y = height / 2,
stars = [],
num_stars = num_stars ? num_stars : 80,
canvas_id = canvas_id;
function create_star() {