Skip to content

Instantly share code, notes, and snippets.

View jowl's full-sized avatar

Joel Segerlind jowl

  • Gothenburg, Sweden
View GitHub Profile
@jowl
jowl / linger_issue.c
Created November 13, 2013 08:50
This gist contains an example showing that LINGER cannot be set after ETERM has been caught (see https://github.com/imatix/zguide/issues/370).
#include <zmq.h>
#include <pthread.h>
#include <assert.h>
static void * worker_routine (void *context) {
char buf;
void *socket = zmq_socket (context, ZMQ_PAIR);
assert( zmq_connect (socket, "inproc://linger") > -1 );
assert( zmq_send(socket, &buf, 1, 0) > -1); // unblock main thread
// zmq_recv will block until context is terminated
@jowl
jowl / gitshot
Created September 17, 2012 11:48
Take photo automatically after every git commit. Run `gitshot --enable` in project base dir to enable.
#!/usr/bin/env ruby
require 'fileutils'
APP = __FILE__.split('/').last
pwd = Dir.pwd
if ARGV.include? '--enable'
post_commit = File.join(pwd,'.git/hooks/post-commit')
abort('post commit hook already exist!') if File.exists?(post_commit)