Skip to content

Instantly share code, notes, and snippets.

@hintjens
hintjens / gist:5480625
Last active February 19, 2022 04:51
Hello World HTTP server using ZeroMQ * Build and install libzmq and CZMQ * Full article on http://hintjens.com/blog:42
// Minimal HTTP server in 0MQ
#include "czmq.h"
int main (void)
{
zctx_t *ctx = zctx_new ();
void *router = zsocket_new (ctx, ZMQ_ROUTER);
zsocket_set_router_raw (router, 1);
int rc = zsocket_bind (router, "tcp://*:8080");
assert (rc != -1);
@hintjens
hintjens / c
Created March 12, 2013 10:28
C helper script, old iMatix magic
#! /bin/sh
#
# c - C compile command
#
# Copyright (c) 1996-2009 iMatix Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or (at
# your option) any later version.
@hintjens
hintjens / core.zip
Created February 21, 2011 12:43
Provoke assertion during zmq_close
@hintjens
hintjens / zwtfpd.c
Created April 29, 2013 09:49
Minimal WTFP server in ZeroMQ
// Minimal WTFP server in 0MQ
#include "czmq.h"
static void *
wtfp_server (void *args)
{
zctx_t *ctx = zctx_new ();
void *router = zsocket_new (ctx, ZMQ_ROUTER);
int rc = zsocket_bind (router, "tcp://*:8080");
assert (rc != -1);
@hintjens
hintjens / git bash prompt
Created March 11, 2011 16:24
git bash prompt, by Pieter Hintjens
export PROMPT_COMMAND=__git_prompt
__git_prompt ()
{
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
@hintjens
hintjens / issue.c
Last active January 1, 2017 17:26
Workaround for issue LIBZMQ-270
#include <zmq.h>
#include <assert.h>
#include <string.h>
#include <unistd.h>
int main (void)
{
void *ctx = zmq_ctx_new ();
assert (ctx);
@hintjens
hintjens / zcurve-poc.c
Last active May 23, 2016 00:41
zcurve -- CurveCP over ZeroMQ -- proof of concept
// Proof of concept CurveCP handshake over 0MQ.
//
// Demonstrates a confidential, authenticated connection between
// two 0MQ peers (two DEALER sockets in this example). See the
// curvecp.org website for details of the security design.
//
// This is a flat walk-through in code with minimal abstraction.
// The next version of this code will be more packaged.
//
// IMPORTANT NOTE: this code has not been reviewed by security experts
@hintjens
hintjens / README.md
Created February 14, 2016 10:59
GYP --generator-output issue

GIST to reproduce this issue.

@hintjens
hintjens / Makefile
Created November 6, 2013 12:51
ZeroMQ TIPC load-balancing example
all: srv.c
g++ srv.c /home/eerihug/dev/BakkaLinux/root/usr/local/lib/libzmq.a -lpthread -lrt -o srv
g++ cli.c /home/eerihug/dev/BakkaLinux/root/usr/local/lib/libzmq.a -lpthread -lrt -o cli
clean:
rm cli
rm srv
@hintjens
hintjens / gist:7302776
Last active December 27, 2015 09:19
Z85 decoder, waaaaay too slow
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
typedef unsigned char byte;
// Maps base 256 to base 85
static char encoder [85 + 1] = {