Skip to content

Instantly share code, notes, and snippets.

View ToxicFrog's full-sized avatar

B. Kelly ToxicFrog

  • Google
  • Kitchener, Ontario
View GitHub Profile
local handlers = setmetatable({}, { __index = function(self, k) self[k] = {}; return self[k]; end; })
event = {}
function event.add(name, fn)
assert(handlers[name][fn] == nil, "attempt to register the same callback multiple times for event " .. name)
handlers[name][fn] = true
return fn
end
#!/bin/bash
#:mode=bash:wrap=soft:
TITLE="RDesktop Frontend"
RDESKTOP_OPTS="-d MY_DOMAIN -g 1024x768 -z"
LEGAL=$(cat <<__EOF__
*** start of legal notice ***
@ToxicFrog
ToxicFrog / rdestop-launcher.py
Created June 26, 2012 02:10
rdesktop-launcher
#!/usr/bin/python
from __future__ import print_function
TITLE = "RDesktop Frontend"
RDESKTOP_COMMAND = "rdesktop"
RDESKTOP_OPTIONS = [ "-d", "MY_DOMAIN", "-g", "1024x768", "-z" ]
LEGAL = """
*** start of legal notice ***
-- invoke as: lua bibgen.lua master.bib paper1.tex paper2.mybib paper3.cites ...
-- a ".tex" or ".latex" file will be parsed for \cite{name} entries
-- anything else will be treated as a newline-separated list of paper names
-- the output file will be the name of the input file, with the extension replaced with ".bib"
-- note: will overwrite files without prompting. Handle with care.
-- parse a BibTeX file into a table of entries indexed by name
local function parsebib(buf)
local bib = {}
(ns ca.ancilla.kessler.lexer
(:use clojure.string))
(defn- lex-token
"Creates and returns the token for the next token in input according to lexer. Throws an exception if input does not match any tokens."
[lexer input]
(let [try-lex (fn [lexeme] (re-find (:pattern lexeme) input))
matching (first (filter try-lex (:lexicon lexer)))]
(if matching
(let [groups (re-find (:pattern matching) input)
(def sfs-lexer
(lexer
["\\s+" :whitespace :drop-token]
["//.*" :comment :drop-token]
["\\{" :open-brace]
["\\}" :close-brace]
["[A-Z]+" :type]
["[a-zA-Z0-9]+" :key]
["=\\s*(.*)" :value #(-> %2)]))
[Desktop Entry]
Name=FTL: Faster Than Light
Comment=A spaceship simulation realtime roguelike-like
Exec=/opt/FTL/FTL
Path=/opt/FTL
Icon=/opt/FTL/data/exe_icon.bmp
Terminal=false
Type=Application
Categories=Game
StartupWMClass=FTL
function staff.callFunctionForEachEmployee(functionName, ...)
if employee_instances then
for _,employee in pairs(employee_instances) do
employee[functionName](employee, ...)
end
end
end
-- or, for a more general approach
function callMethodOnEach(objects, method, ...)
@ToxicFrog
ToxicFrog / EPL-ISRU.cfg
Last active January 3, 2016 23:53
MM patches for EPL
@PART[ISRU]:FINAL
{
MODULE
{
name = ModuleResourceConverter
ConverterName = RocketParts
StartActionName = Start ISRU [Rocket Parts]
StopActionName = Stop ISRU [Rocket Parts]
AutoShutdown = false
GeneratesHeat = false
function love.conf(t)
t.name = "Example project -- tests"
t.author = "ToxicFrog"
t.identity = "example.test"
t.version = "0.9.0" -- replace with target love2d version
t.console = true -- enable console on windows for debug logging
-- disable all module loading
-- if some of your tests actually call love2d API functions, either enable them or provide stubs