Skip to content

Instantly share code, notes, and snippets.

@losinggeneration
losinggeneration / except.go
Created October 4, 2012 16:02
A quick and dirty exception handler for the Go programming language
/*
MIT license:
Copyright (c) 2012 Harley Laue <losinggeneration@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
@losinggeneration
losinggeneration / rss.go
Created September 25, 2012 15:13
Possible Go RSS formatter
package rss
import "encoding/xml"
type Channel struct {
XMLName xml.Name `xml:"channel"`
Title string `xml:"title"`
Description string `xml:"description"`
Link string `xml:"url"`
LastBuildDate string `xml:"lastBuildDate"`
@losinggeneration
losinggeneration / muxchain_kitten.go
Created May 18, 2014 15:41
This is a fix to the muxchain kitten example in https://stephensearles.com/?p=254
func main() {
m := muxchainutil.NewMethodMux()
m.Handle("GET /kitten", http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
f, _ := os.Open("kitten.jpg")
defer f.Close()
io.Copy(w, f)
}))
http.ListenAndServe(":3000", m)
@losinggeneration
losinggeneration / lock.moon
Created March 24, 2014 15:02
Warlock Lua->Moon (just for fun)
--
-- Set a lock
--
-- KEYS[1] - key
-- KEYS[2] - ttl in ms
-- KEYS[3] - lock content
{key, ttl, content} = KEYS
lockSet = redis.call 'setnx', key, content