Skip to content

Instantly share code, notes, and snippets.

View stevedonovan's full-sized avatar

Steve J Donovan stevedonovan

View GitHub Profile
@stevedonovan
stevedonovan / array.lua
Created March 26, 2012 12:35
Covariance with pl.class: a specialized List of numbers
require 'pl'
class.Array(List)
function Array.__add (a1,a2)
return a1:map2('+',a2)
end
function Array.__sub (a1,a2)
return a1:map2('-',a2)
@stevedonovan
stevedonovan / deb.lua
Created May 8, 2012 11:53
Correspondance between Lua modules and Debian packages (from ldeb)
local packages = {
bit="liblua5.1-bitop0", -- -- fast bit manipulation library for the Lua language v
cgilua="liblua5.1-cgi0", -- -- CGI library for the Lua language version 5.1
sapi="liblua5.1-cgi0", -- -- CGI library for the Lua language version 5.1
copas="liblua5.1-copas0", -- -- Copas is a dispatcher of concurrent TCP/IP requests
cosmo="liblua5.1-cosmo0", -- -- A template library for the Lua langua version 5.1
coxpcall="liblua5.1-coxpcall0", -- -- Protected function calls across coroutines for Lua 5
curl="liblua5.1-curl0", -- -- libcURL bindings for the Lua language version 5.1
luaevent="liblua5.1-event0", -- -- asynchronous event notification library for Lua vers
lxp="liblua5.1-expat0", -- -- libexpat bindings for the Lua language version 5.1
@stevedonovan
stevedonovan / foo.c
Created May 25, 2012 10:07
A Lua script to embed Lua code in a C module.
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#ifdef WIN32
#define EXPORT __declspec(dllexport)
#else
#define EXPORT
#endif
static const char * lua_code = \
@stevedonovan
stevedonovan / ChartExample.java
Last active January 13, 2022 09:36
Android Example using AChartEngine to plot JSON data
package com.example.testchart;
import java.util.*;
import java.io.*;
import java.text.DateFormat;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.*;
@stevedonovan
stevedonovan / mockup.ltp
Created October 11, 2012 05:59
Penlight-style Lua template for HTML with JavaScript; note @ used as escape!
<!DOCTYPE HTML>
<html>
<head>
<script src="/flot/jquery.min.js" type="text/javascript"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="/media/flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="/flot/jquery.flot.min.js"></script>
<script language="javascript" type="text/javascript" src="/flot/jquery.flot.navigate.js"></script>
<style type="text/css">
.center { text-align:center; }
@stevedonovan
stevedonovan / struct.lua
Created November 19, 2012 12:56
'Strict' Structs in Lua.
-- struct.lua
--- defining a struct constructor ---
local function ordered_map (t)
local fields,keys = {},{}
for i,item in ipairs(t) do
local key,value = next(item)
fields[key] = value
keys[i] = key
end
@stevedonovan
stevedonovan / globalsplus.lua
Last active December 11, 2015 12:48
An extended undefined variable checker for Lua 5.1 using bytecode analysis based on David Manura's globalplus.lua http://lua-users.org/wiki/DetectingUndefinedVariables
-- globalsplus.lua
-- Like globals.lua in Lua 5.1.4 -- globalsplus.lua
-- Like globals.lua in Lua 5.1.4 but records fields in global tables too.
-- Probably works but not well tested. Could be extended even further.
--
-- usage: lua globalsplus.lua example.lua
--
-- D.Manura, 2010-07, public domain
--
-- See http://lua-users.org/wiki/DetectingUndefinedVariables
@stevedonovan
stevedonovan / form.moon
Created January 29, 2013 12:14
Simple Android Activity in MoonScript using AndroLua
require 'android'
require 'android.intents' -- needed for creating an email..
feedback_email = 'appfeedback@yourappsite.com'
_M = android.new!
with _M
-- compare to this more standard implementation:
--http://mobile.tutsplus.com/tutorials/android/android-sdk-creating-forms/
@stevedonovan
stevedonovan / ld-parse.lua
Last active December 15, 2015 12:48
LuaDist batteries manifest; all modules which are directly installable. Third field is either 'no', 'yes' or <version> if there exists a higher version in the repo. A start made with annotating these entries with tags.
local f = io.open('info.txt')
local line = f:read()
local Q = '"'
local QC = '",'
--local tags = dofile 'tags.lua'
@stevedonovan
stevedonovan / lint64.c
Last active May 18, 2016 06:44
An int64 module, for Lua 5.1/5,2, by Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>, as extended by Steve Donovan (steve.j.donovan@gmail.com)
/*
* lint64.c
* int64 nummbers for Lua
* Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>
* Thu Aug 1 22:56:17 BRT 2013
* This code is hereby placed in the public domain.
* Modified by Stevedonovan, Aug 3.
* __pow is defined by integer second arg
* new can be passed a hex literal string
* tohex will return a int64 as a hex string