Skip to content

Instantly share code, notes, and snippets.

View daurnimator's full-sized avatar

daurnimator

View GitHub Profile
Array.prototype.random=function(){return this[Math.floor(Math.random()*this.length)]};
var keydown = getEventListeners(document).keydown[0].listener
setInterval(function () { keydown({which:[38,39,40,37].random(), preventDefault:function(){}}) },5)
@daurnimator
daurnimator / gist:0d52d5ac899f07b1063a
Created August 2, 2014 03:23
Tampermonkey script: Reverse colours in twitch chat
// ==UserScript==
// @name Reverse colours in twitch chat
// @namespace http://daurnimator.com
// @version 0.1
// @description Reverse colours in twitch chat
// @match http://www.twitch.tv/daurnimator/chat?popout=
// @copyright 2014+, Daurnimator
// ==/UserScript==
GM_addStyle('.ember-chat .chat-messages .chat-line { color: #fff }')
@daurnimator
daurnimator / prosody.service
Created August 4, 2014 01:55
systemd unit for prosody; assumes mod_systemd
[Unit]
Description=XMPP (Jabber) Server
After=network.target
[Service]
User=prosody
ProtectSystem=full
ProtectHome=true
Type=notify
ExecStart=/usr/bin/prosody
@daurnimator
daurnimator / xmppstream.diff
Created August 7, 2014 19:56
Patch to prosody's xmppstream to allow stream pipelining
diff -r 93b8438fe761 util/xmppstream.lua
--- a/util/xmppstream.lua Thu Aug 07 12:35:12 2014 -0400
+++ b/util/xmppstream.lua Thu Aug 07 15:55:16 2014 -0400
@@ -227,6 +227,7 @@
function new(session, stream_callbacks, stanza_size_limit)
-- Used to track parser progress (e.g. to enforce size limits)
local n_outstanding_bytes = 0;
+ local current_data
local handle_progress;
if lxp_supports_bytecount then
@daurnimator
daurnimator / PKGBUILD
Last active August 29, 2015 14:05
PKGBUILD for lua-systemd. Generated with https://gist.github.com/daurnimator/11148106 then hand edited.
pkgname='lua-systemd'
pkgver='scm_0'
pkgrel='0'
pkgdesc='Lua bindings to systemd'
arch=('any')
url='https://github.com/daurnimator/lua-systemd'
license=('MIT')
depends=('luarocks' 'lua')
source=('systemd-scm-0.rockspec' 'git://github.com/daurnimator/lua-systemd')
md5sums=('SKIP' 'SKIP')
@daurnimator
daurnimator / output
Last active August 29, 2015 14:07
Demostration of seek_tail issue.
CUTOFF = 1413177397982789
TAIL = 0
NEXT = 1
FOUND from 1400437372012374
NEXT = 1
FOUND from 1400438753925868
NEXT = 1
FOUND from 1400438753926192
NEXT = 1
FOUND from 1400438753926257
@daurnimator
daurnimator / gist:e0a3215d93252645812b
Created October 19, 2014 20:03
For bsdfox from #lua
#!/usr/bin/lua
local evdev = require "evdev"
local pirsensor = evdev.Device "/dev/input/event0"
local cqueues = require "cqueues"
local sleeptime = 10
local pending = nil
-- ensure backlight is off to start
os.execute("/home/h36sa/Projects/fbtft/backlight_off.sh")
@daurnimator
daurnimator / weird.strace
Created October 22, 2014 17:57
Blocking read with O_NONBLOCK set? (please ignore sending xml to ssh :P)
dup(12) = 13
getsockname(13, {sa_family=AF_INET, sin_port=htons(46811), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
getsockopt(13, SOL_SOCKET, SO_TYPE, [1], [4]) = 0
fstat(13, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
getsockname(13, {sa_family=AF_INET, sin_port=htons(46811), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
getsockopt(13, SOL_SOCKET, SO_TYPE, [1], [4]) = 0
fcntl(13, F_SETFD, FD_CLOEXEC) = 0
fcntl(13, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
fcntl(13, F_SETFL, O_RDWR|O_NONBLOCK) = 0
setsockopt(13, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
@daurnimator
daurnimator / ngx_http_lua_cqueues.c
Last active August 29, 2015 14:12
ngx lua function to allow waiting for a file descriptor to be ready
#include "ngx_http_lua_cqueues.h"
#include <math.h> /* HUGE_VAL */
#include <stdlib.h> /* calloc, free */
#include <lua.h>
#include <lauxlib.h>
#include "ngx_core.h"
#include "ngx_http.h" /* ngx_http_request_t, ngx_http_run_posted_requests */
@daurnimator
daurnimator / stdin
Created January 19, 2015 19:12
stdin
# HG changeset patch
# User daurnimator <quae@daurnimator.com>
# Date 1421694071 18000
# Mon Jan 19 14:01:11 2015 -0500
# Node ID 8921aaedeea7a48630c2396c2c45eeaf6abf8b22
# Parent 31a8b3bfb31d6145c3a8a2b789d2d3f92eed0dc9
net.server_select: Remove do-nothing os_difftime calls
diff -r 31a8b3bfb31d -r 8921aaedeea7 net/server_select.lua
--- a/net/server_select.lua Thu Jan 15 09:05:08 2015 -0500