Skip to content

Instantly share code, notes, and snippets.

View stuartpb's full-sized avatar

Stuart P. Bentley stuartpb

View GitHub Profile
#! /home/stuserbot/bin/lua
local rt = {}
local getenv = os.getenv
local strupper = string.upper
local strlower = string.lower
local format = string.format
local gsub = string.gsub
local setmetatable = setmetatable
local write = io.write
# the full list is at http://www.scintilla.org/SciTEDoc.html #
#settings provided in Lua for Windows' SciTEGlobal.properties
import minilfw
#font change
font.base=font:Consolas,size:8
font.small=$(font.base)
font.comment=$(font.base)
font.code.comment.box=$(font.comment)
local iup = require "iuplua"
local cairo = require "lcairo"
local drawf, errmsg
local function showerr(hdc, err)
uhoh = cairo.CreateContext(hdc)
cairo.set_source_rgb(uhoh,1,0,0)
cairo.select_font_face (uhoh,"Consolas",
cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_BOLD)
@stuartpb
stuartpb / gist:1023370
Created June 13, 2011 18:27
A nice environmental module style for 5.2
--takes the environment to encapsulate
local function modme(encenv)
local retmod = {}
local envmt = {}
function envmt.__index(t, k)
return retmod[k] or encenv[k]
end
function envmt.__newindex(t, k, v)
retmod[k] = v
end
@stuartpb
stuartpb / gist:1023377
Created June 13, 2011 18:32
Classic style 5.2 environmental module function
--has the same signature as classic module (almost)
local function module(name, encenv)
local mod_t = {}
local envmt = {}
function envmt.__index(t, k)
return mod_t[k] or encenv[k]
end
function envmt.__newindex(t, k, v)
mod_t[k] = v
@stuartpb
stuartpb / drag.lua
Created October 3, 2011 20:21
grab, drag, and release handler framework for IUPLua
do
local dox, doy
local function drag(x, y)
end
local function grab(x, y)
dox, doy = x, y
drag(x, y)
end
local function release(x, y)
dox, doy = nil, nil
@stuartpb
stuartpb / gist:1343278
Created November 6, 2011 18:24
A hacky bit of code I wrote up in a couple seconds to make the table constructors for some glyphs
for _,s in ipairs{"AZ","09","!!","??","::","..","--"} do
local b1=string.byte(s:sub(1,1))
local b2=string.byte(s:sub(2,2))
for i=b1, b2 do
print(string.format([[
[%q]={
{},
},]],string.char(i)))
end
end
@stuartpb
stuartpb / gist:2849608
Created June 1, 2012 06:42
something like xscreensaver's default text
hostname
uname -sr
date
uptime
@stuartpb
stuartpb / resume.mustache
Created July 18, 2012 20:29
stuartpbentley.com mustache experiment
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Stuart P. Bentley</title>
<link rel="shortcut icon" href="stuhat.svg">
<style>
h1, h2, h3, h4, h5, h6, header, address {
margin: 0;
padding: 0;
@stuartpb
stuartpb / hilbert.js
Created August 10, 2012 20:59 — forked from rbedia/hilbert.js
Hilbert demo
/*
* Copyright 2010 Barricane Technology Ltd., All rights reserved.
*
* Released under the MIT licence.
*/
/**
* Battenburg is simply a 2x2 matrix with non-mutating
* methods.
*