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 buf = {}
for i=#out_number,1,-1 do
table.insert(buf, out_number:sub(1, i))
end
fsLog("MY VARIABLE", table.concat(buf, ", "))
class Foo(_name: String) {
def name = _name
def equals(other: Foo) = {
println(this, other, name, other.name, name equals other.name)
_name equals other.name
}
}
val (one,two,three) = (new Foo("one"), new Foo("two"), new Foo("three"))
val s = Seq[Foo](one, two, three)
-- function f() return foo.bar[1] end
function <stdin:1,1> (5 instructions, 20 bytes at 0x1e19410)
0 params, 2 slots, 0 upvalues, 0 locals, 3 constants, 0 functions
1 [1] GETGLOBAL 0 -1 ; foo
2 [1] GETTABLE 0 0 -2 ; "bar"
3 [1] GETTABLE 0 0 -3 ; 1
4 [1] RETURN 0 2
5 [1] RETURN 0 1
-- function g() return foo[1] end
@ECHO OFF
MODE CON: COLS=120
TITLE KSP SFSEdit
CALL :FindJRE
:RunEditor
"%JAVAPATH%\bin\java.exe" -jar kessler/sfsedit.jar saves/default/persistent.sfs
PAUSE
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)]))