Skip to content

Instantly share code, notes, and snippets.

Steve J Donovan stevedonovan

Block or report user

Report or block stevedonovan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
stevedonovan / StringAccessor.lua
Created Dec 20, 2010
A Lua class for accessing individual characters in a string
View StringAccessor.lua
--[[ Example:
sa = StringAccessor 'hello'
for c in sa:iter() do
stevedonovan / safe_array.lua
Created Dec 30, 2010
This defines an array with strict bounds checking. It is also impossible to set any existing index to a nil value, so the array remains free of holes. The table functions will not work on such arrays because they are userdata, giving an extra layer of pro
View safe_array.lua
local function out_of_range(i,n)
if type(i) == 'number' then
if i > 0 and i <= n then return true
else error('out of range',3)
error 'cannot index array by non-number type'
stevedonovan / lua_prompt.lua
Created Mar 28, 2011
An interactive Lua prompt for the Textadept editor
View lua_prompt.lua
-- makes interactive prompt dodgy.
-- (In an ideal world, should be able to switch this off only for
-- the message buffer)
_m.textadept.editing.AUTOPAIR = false
-- useful function which can safely handle argument lists containing nil;
-- the resulting table has n set to the real length.
local function pack (...)
local args = {...}
args.n = select('#',...)
stevedonovan / prettify.lua
Created Aug 11, 2011
Script to convert Markdown source with code blocks into syntax-highlighted HTML.
View prettify.lua
-- translate Markdown with code blocks into HTML
-- with syntax highlighting.
-- If was the source, Lua was the language and we
-- wanted a preview:
-- lua prettify.lua article lua preview
-- Without the last argument it will just write out the HTML body.
-- Languages supported are 'lua', 'cpp', 'java' and 'go
-- Indented code blocks may begin with an explicit @lang name line;
-- if you do this then mark every code block explicitly
-- e.g
stevedonovan / css.lua
Created Aug 30, 2011
A little Lua DSL for generating CSS
View css.lua
A Lua module that defines a little DSL for generating CSS
-- csstest.lua
require 'css'
width = 500
lmargin = 50
leftm = 150
gap = 10
stevedonovan / html.lua
Created Sep 5, 2011
Orbit-style Htmlification using LuaExpatUtils
View html.lua
Example usage:
-- test2.lua
require 'html'
html {
body { title 'Test' },
h2 'title',
p 'first para',
stevedonovan / loader.lua
Created Oct 19, 2011
A Custom Lua module loader for Lua 5.2
View loader.lua
-- This allows a more restricted module() style; the key feature
-- is that each module is loaded in a custom environment, and the actual module
-- table is a copy of that environment after initial load.
-- clone _G so that globals from the program don't invade the module
local lua_libs = {}
for k,v in pairs(package.loaded._G) do
lua_libs[k] = v
stevedonovan / csvdta.go
Created Dec 2, 2011
A Go package which reads structure data from CSV data using reflection
View csvdta.go
package csvdata
// csvdata complements the csv package by allowing you to map a custom structure to
// the columns of data in a CSV file. The struct needs to be annotated so that each
// field can match a column in the data
// type Person struct {
// FirstName string `field:"First Name"`
// Second_Name string
// Age int
// }
stevedonovan / list.moon
Created Dec 15, 2011
An example of a MoonScript class
View list.moon
import insert,concat,remove from table
class List
new: (t) =>
@ls = t or {}
add: (item) =>
insert @ls,item
stevedonovan / ml.lua
Created Feb 15, 2012
Microlight - a really compact set of general Lua functions
View ml.lua
-- Microlight - a very compact Lua utilities module
-- Steve Donovan, 2012; License MIT
-- @module ml
local ml = {}
--- String utilties.
-- @section string
You can’t perform that action at this time.