Skip to content

Instantly share code, notes, and snippets.

@srid
srid / subcommand.go
Created October 24, 2012 22:52
golang simple subcommand parser
// A simple sub command parser based on the flag package
package subcommand
import (
"flag"
"fmt"
"os"
)
type subCommand interface {
@max747
max747 / client.py
Last active December 17, 2015 12:09
pyzmq のクライアント側を multiprocessing でぶん回す実験
import zmq
import functools
import random
import sys
from multiprocessing import Pool
class Client(object):
def __init__(self, client_id, addr):
self.ctx = zmq.Context()
@danieltdt
danieltdt / install.sh
Created June 2, 2013 08:51
Install UnQLite as a shared library on Linux (tested on ubuntu 12.04).
#!/usr/bin/env bash
# Before executing it, you must download UnQLite source code (http://www.unqlite.org/downloads.html)
# unzip all the files and execute this script inside the unzipped folder. For example:
# mkdir /tmp/unqlite; cd /tmp/unqlite; unzip ~/Downloads/unqlite-db-116.zip
gcc -Wall -fPIC -c *.c
gcc -shared -Wl,-soname,libunqlite.so.1 -o libunqlite.so.1.0 *.o
sudo cp `pwd`/libunqlite.so.1.0 /usr/local/lib/
sudo cp `pwd`/unqlite.h /usr/local/include/
sudo ln -sf /usr/local/lib/libunqlite.so.1.0 /usr/local/lib/libunqlite.so.1
@dmitshur
dmitshur / gist:6927554
Last active July 14, 2024 16:13
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.
@dropwhile
dropwhile / py27.txt
Last active June 3, 2019 13:51
python-2.7.14 and python-3.7.0 -- for centos7 (rpm fpm recipes)
##### Configurable options
BUILD_VER=2.7.14
# strip symbols to slightly reduce runtime memory footprint
STRIP="yes"
# use altinstall to NOT symlink python and python2 to the python2.7 executable
ALTINSTALL="yes"
# build as user, requires configured sudo (for yum and fpm gem install).
# if not "yes", then build should be done as root
USE_SUDO="yes"
@arms22
arms22 / fiber.h
Last active January 2, 2016 08:49
C言語用コルーチン。マイクロスレッドとかファイバーとかそんなやつ。Arduino用に極力シンプルに実装。gccのラベル拡張使ってるからgcc専用。実行結果:fiber test0 0 1 1 1 1 2 2 2 3 3 4 4 5 9
#ifndef FIBER_H
#define FIBER_H
#define FIBER_NEST_ENABLE 1
typedef void* fiber_t;
#define FIBER_INIT { ((void*)0) }
#define FIBER_LINE2(x) FIBER_LINE_ ## x
#define FIBER_LINE(x) FIBER_LINE2(x)
@fiorix
fiorix / sse.go
Last active June 27, 2024 02:15
Go and Server Sent Events for HTTP/1.1 and HTTP/2.0
// Go and Server Sent Events for HTTP/1.1 and HTTP/2.0
//go:generate go run $GOROOT/src/crypto/tls/generate_cert.go -host localhost
package main
import (
"fmt"
"io"
"log"
"net/http"
@perpen
perpen / docker-from-chromeos.sh
Last active February 6, 2018 21:49
Script for running docker in Chrome OS
#!/bin/sh
## Requires custom kernel to be installed in Chrome OS
## Copies files from my archlinux chroot into a temp folder and runs docker from there.
## Running this on boot of Chrome OS so my version of the docker daemon is upgraded by
## pacman in the chroot.
set -e
chroot=/usr/local/chroots/arch
run=/usr/local/tmp/docker
@iamralch
iamralch / sshtunnel.go
Last active April 16, 2023 03:07
SSH tunnelling in Golang
package main
import (
"log"
"bufio"
"time"
"os"
"fmt"
"io"
"net"