Skip to content

Instantly share code, notes, and snippets.

View daurnimator's full-sized avatar

daurnimator

View GitHub Profile
@daurnimator
daurnimator / ndp-scm.3ddc836b7845-0.rockspec
Created January 28, 2015 01:38
ndp "natural date parser" rockspec
package = "ndp"
version = "scm.3ddc836b7845-0"
source = {
url = "http://code.matthewwild.co.uk/ndp/archive/3ddc836b7845.zip";
dir = "ndp-3ddc836b7845";
}
description = {
summary = "ndp is a 'natural date parser' library.";
detailed = [[
ndp is a "natural date parser" library. It allows you to
@daurnimator
daurnimator / main.lua
Last active August 29, 2015 14:15
Example AIO library for lua
local cqueues = require "cqueues"
local syscall = require "syscall"
local aio = {}
local aio_mt = {__index = aio}
local function new_aio(n)
local self = setmetatable({
n = n or 20;
id = nil;
@daurnimator
daurnimator / install-pgdg.yml
Created February 13, 2015 16:36
Ansible Task to add Postgres' pgdg apt repo
- name: install | Add pgdg key
apt_key: url=https://www.postgresql.org/media/keys/ACCC4CF8.asc id=ACCC4CF8
tags: [postgres]
- name: install | Add pgdg apt repository
apt_repository: repo='deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main'
tags: [postgres]
from jinja2.runtime import Undefined
SPECIAL_DELIM = [("[{}[".format("="*n), "]{}]".format("="*n)) for n in range(10)]
def type_of(v, *types):
return any(isinstance(v, t) for t in types)
def get_delim(s):
if '"' not in s and "\n" not in s and "\\" not in s:
return ('"', '"')
@daurnimator
daurnimator / .bashrc
Created February 21, 2015 02:48
Python portion of my .bashrc
# Python
export PIP_DOWNLOAD_CACHE=$HOME/.pip_download_cache
source /usr/bin/virtualenvwrapper.sh
alias virtualenv-mk=mkvirtualenv
alias virtualenv-exit=deactivate
alias virtualenv-use=workon
complete -o default -o nospace -F _virtualenvs virtualenv-use
alias virtualenv-rm=rmvirtualenv
complete -o default -o nospace -F _virtualenvs virtualenv-rm
alias virtualenv-cp=cpvirtualenv
@daurnimator
daurnimator / gist:a61d223df1f83da8b72a
Created March 14, 2015 21:05
TamperMonkey script - Better dimensions for Glowing Bear
// ==UserScript==
// @name Better dimensions for Glowing Bear
// @namespace http://daurnimator.com
// @version 0.1
// @description Glowing Bear sidebar dimensions
// @author Daurnimator
// @match http://www.glowing-bear.org/
// @grant GM_addStyle
// ==/UserScript==
@daurnimator
daurnimator / cqueues-tohostname.lua
Created March 21, 2015 04:23
cqueues.socket.tohostname
local unpack = table.unpack or unpack
local socket = require "cqueues.socket"
local dns = require "cqueues.dns"
function socket.tohostname(type, address)
local rev
if type == socket.AF_INET or type == "AF_INET" then
local o1, o2, o3, o4 = address:match("^([12]?%d%d?)%.([12]?%d%d?)%.([12]?%d%d?)%.([12]?%d%d?)$")
if o1 == nil then error("invalid address") end
rev = string.format("%s.%s.%s.%s.in-addr.arpa", o4, o3, o2, o1)
elseif type == socket.AF_INET6 or type == "AF_INET6" then
@daurnimator
daurnimator / keybase.md
Created April 17, 2015 02:02
keybase.md

Keybase proof

I hereby claim:

  • I am daurnimator on github.
  • I am daurnimator (https://keybase.io/daurnimator) on keybase.
  • I have a public key whose fingerprint is 954A 3772 D62E F90E 4B31 FBC6 C91A 9911 192C 187A

To claim this, I am signing this object:

@daurnimator
daurnimator / .bashrc
Created June 5, 2015 03:12
Lua segment of my .bashrc
# Lua
export LUA_INIT='function p(o) for k,v in pairs(o) do print(k,v) end end;'
alias luajit='rlwrap luajit'
LUA_PATH="./?/init.lua;;"
LUA_CPATH=";;"
## For 5.3
export LUA_PATH_5_3="$LUA_PATH;/usr/local/share/lua/5.3/?/init.lua;/usr/local/share/lua/5.3/?.lua"
export LUA_CPATH_5_3="$LUA_CPATH;/usr/local/lib/lua/5.3/?.so"
## For 5.2
export LUA_PATH_5_2="$LUA_PATH;/usr/local/share/lua/5.2/?/init.lua;/usr/local/share/lua/5.2/?.lua"
@daurnimator
daurnimator / fifo.c
Created June 14, 2015 03:39
exposing cqeueus fifo header
#include "lua.h"
#include "lauxlib.h"
#include "lib/fifo.h"
#include "cqueues.h"
#include <string.h> /* strerror */
#include <locale.h> /* localconv */
#include <ctype.h> /* isspace, isdigit, isxdigit */
static int lfifo_new(lua_State *L) {
size_t size;