Skip to content

Instantly share code, notes, and snippets.

@zenlor
zenlor / mongo_pubsub.rb
Created August 30, 2011 13:58 — forked from octplane/mongo_pubsub.rb
Simple Pub/Sub system using MongoDB, capped collections and tailable cursors in ruby
require 'rubygems'
require 'mongo'
module MongoPubSub
QUEUES_COLLECTION = 'queues'
class EndSubscriptionException < Exception; end
class Publisher
def initialize(queue_name, mongo_connection)
# Initialize queue collection as a capped collection
if not mongo_connection[QUEUES_COLLECTION].collection_names.include?(queue_name)
@zenlor
zenlor / Benchmark-ish.js
Created December 26, 2011 15:35
walk(dirname, callback, finished) - asynchronous directory traversal in node.js
var fs = require('fs')
, path = require("path")
, cp = require('child_process')
, Step = require('step')
, colors = require('colors')
, start = Date.now();
walk = (function() {
var counter = 0;
var walk = function(dirname, callback, finished) {
{
"base_url":"http://example.com/launcher/v1",
"server_id":"",
"name": "MagiTech Madness",
"news":"http://example.com/launcher/v1/index.html",
"address":"",
"revision":"0.0.1",
"version":"1.6.4"
}
@zenlor
zenlor / bookmarklet
Last active August 29, 2015 14:13 — forked from mauricecruz/readme.md
(function(d, u) {
var s = d.createElement('script');
s.src = u;
s.async = !!1;
(d.head || d.getElementsByTagName('head')[0]).appendChild(s);
}(document, 'https://gist.githubusercontent.com/mauricecruz/d20345b25b5c3ca0a4d7/raw/3f0a90112026a1e51a401dcb2fe6f3ca7bf299c0/snippet.js'));
(function(d){var a=d.createElement("script");a.src="https://gist.githubusercontent.com/mauricecruz/d20345b25b5c3ca0a4d7/raw/3f0a90112026a1e51a401dcb2fe6f3ca7bf299c0/snippet.js";a.async=!0;d.head.appendChild(a);}(document))();
@zenlor
zenlor / onchange.sh
Last active August 29, 2015 14:15 — forked from shello/onchange.sh
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute a command
# when a file or directory is created, modified or deleted.
#
# Modified from the original by: Senko Rasic <[email protected]>
# https://gist.github.com/senko/1154509
#
# Requires:
# bash
# -- Conky settings -- #
background no
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
override_utf8_locale yes
double_buffer yes
@zenlor
zenlor / sql-tdd.markdown
Created November 14, 2016 16:54 — forked from abrkn/sql-tdd.markdown
Migrations and testing for PostgreSQL using node.js and Travis-CI

Migrations and testing for PostgreSQL using node.js and Travis-CI

We're looking to add a column to the table user called admin (boolean) in an existing database.

Project layout

migrations
@zenlor
zenlor / hook.sh
Last active November 21, 2016 10:56 — forked from jimmycuadra/hook.sh
letsencrypt.sh hook script for dns-01 challenge using AWS Route 53
#!/bin/sh
HOSTED_ZONE="Route53 zone ID"
payload() {
local action=$1
cat <<EOF
{
"Changes": [
{ "Action": "${action}",
@zenlor
zenlor / pretty-pragmata.el
Created November 30, 2016 22:47 — forked from plaidfinch/pretty-pragmata.el
Mappings for prettify-symbols-mode to enable Pragmata Pro's ligatures in Emacs. I've taken some slight liberties with the original ligature map, to suit my own tastes.
;; PRETTIFY SYMBOLS (with Pragmata Pro)
(defun setup-pragmata-ligatures ()
(setq prettify-symbols-alist
(append prettify-symbols-alist
'(("!!" . ?)
("!=" . ?)
("!==" . ?)
("!≡" . ?)
("!≡≡" . ?)
("!>" . ?)
@zenlor
zenlor / alpine-chroot.sh
Last active May 12, 2019 10:15 — forked from emolitor/alpine-chroot.sh
chroot script for testing aarch64
#!/bin/sh
#
# This simple script is setting up a Alpine Linux installation in a chroot.
# chroot will be placed in the current working directory.
#
# Most parts of this script are written down at
# http://wiki.alpinelinux.org/wiki/Setting_up_the_build_environment_in_chroot
#
# Licensed under GPLv2
#