Skip to content

Instantly share code, notes, and snippets.

View oal's full-sized avatar

Olav Lindekleiv oal

View GitHub Profile
@oal
oal / threejs.coffee
Created March 6, 2013 12:44
A short example showing how to subclass THREE.Mesh in CoffeeScript.
class Entity extends THREE.Mesh
constructor: ->
geometry = new THREE.CubeGeometry(200,200,200)
material = new THREE.MeshBasicMaterial
color: 0xffffff
THREE.Mesh.call @, geometry, material
@oal
oal / gist:7679396
Created November 27, 2013 17:12
Schema and configuration example for using SQLite with OpenSMTPD.
# sqlite.conf
dbpath /mail/mail.db
query_alias select value from aliases where key=?;
query_domain select domain from domains where domain=?;
query_userinfo select uid, gid, directory from users where user=?;
query_credentials select key, value from credentials where key=?;
query_netaddr select value from netaddr where value=?;
@oal
oal / slugify.d
Created February 28, 2014 13:58
Simple slugify function for D
import std.stdio;
import std.uni;
import std.ascii;
import std.string;
import std.algorithm;
import std.range;
string slugify(string text) {
text = normalize!NFKD(text);
auto slug = "";
@oal
oal / crypt.go
Last active August 29, 2015 13:58
Crypt binding for Go
package crypt
// #cgo LDFLAGS: -lcrypt
// #include <stdlib.h>
// #include <crypt.h>
import "C"
import "unsafe"
func Crypt(key, salt string) string {
cKey := C.CString(key)
# Based on http://www.chris-reilly.org/blog/technotes/macbook-trackpad-in-ubuntu/
Section "InputClass"
MatchIsTouchpad "on"
Identifier "Touchpads"
Driver "mtrack"
Option "Sensitivity" "0.55"
Option "FingerHigh" "12"
Option "FingerLow" "1"
Option "IgnoreThumb" "true"
@oal
oal / router.go
Last active August 29, 2015 14:03
"Strict slash" in Beego router
// Put this in your router.go
// I wasn't able to find any settings for this in Beego, so I created this middleware.
import "strings"
beego.InsertFilter("*", beego.BeforeExec, func(ctx *context.Context) {
path := ctx.Request.URL.Path
if path[len(path)-1] != '/' && strings.Index(path, "/static/") != 0 {
ctx.Redirect(301, path+"/")
}
@oal
oal / userContent.css
Created July 6, 2014 15:07
Cut Tweetdeck columns in half and remove scroll bars.
@-moz-document domain(tweetdeck.twitter.com) {
.app-columns {
display: flex;
flex-flow: row wrap;
}
.column {
flex: 1 20% !important;
height:50% !important;
}
@oal
oal / gist:e965bc6fd031f27f9f86
Created December 25, 2014 13:21
Restart Safari and reopen all windows and tabs from previous session.
function run() {
// Quit
var safari = Application('Safari');
safari.activate();
safari.quit()
// Reopen safari
safari.activate();
// Get menu
def load_obj(file):
vertices = []
lines = []
with open(file, 'r') as f:
for line in f: # loop over lines in file
if line[0] == 'v': # lines starting with 'v' is a vertex
vertices.append([float(x) for x in line.split(' ')[1:]]) # split on spaces, skip first character (v)
elif line[0] == 'f': # face (4 points)
i = 0
@oal
oal / SymbolToHTML.json
Created March 5, 2015 10:11
A mapping of characters used by the Symbol font in MS Word to HTML symbols
{
"61505": "&Alpha;",
"61506": "&Beta;",
"61507": "&Chi;",
"61508": "&Delta;",
"61509": "&Epsilon;",
"61510": "&Phi;",
"61511": "&Gamma;",
"61512": "&Eta;",
"61513": "&Iota;",