Skip to content

Instantly share code, notes, and snippets.

@daschl
daschl / couchbase-php-handler.php
Created June 25, 2012 06:15
A reference implementation of a Couchbase Session Handler with PHP
<?php
/**
* A reference implementation of a custom Couchbase session handler.
*/
class CouchbaseSessionHandler implements SessionHandlerInterface {
/**
* Holds the Couchbase connection.
*/
@submachine
submachine / gen_rand_dag.c
Created October 9, 2012 00:37
A quick-n-dirty random DAG generator
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* http://stackoverflow.com/q/12790337/274261 */
/* Generates random DAGs. The key is to 'rank' the nodes, and
only draw edges from lower ranked nodes to higher ranked ones. */
/* Nodes/Rank: How 'fat' the DAG should be. */
@cespare
cespare / log.go
Created October 31, 2012 06:51
Golang apache logging
type ApacheLogRecord struct {
http.ResponseWriter
ip string
time time.Time
method, uri, protocol string
status int
responseBytes int64
elapsedTime time.Duration
}
@citrin
citrin / range2cidr.c
Created December 4, 2012 11:28
Convert IPv4 range to list of CIDR prefixes
#include <arpa/inet.h>
#include <assert.h>
#include <err.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#define IPv4_BITS 32
@benbjohnson
benbjohnson / README.md
Last active February 11, 2019 12:10
LuaJIT + Go Integration Test

Create an empty directory, download the code and run it:

$ mkdir /tmp/lj
$ cd /tmp/lj
$ wget https://gist.github.com/benbjohnson/5622779/raw/e53d227ebdbea8d513b62ad076feb3f6ac1c1594/luajit.go
$ go run luajit.go

And you should see:

@willurd
willurd / web-servers.md
Last active July 22, 2024 15:25
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@flc
flc / image.go
Created September 4, 2013 14:17
A Tour of Go - Exercise: Images http://tour.golang.org/#60
package main
import (
"code.google.com/p/go-tour/pic"
"image"
"image/color"
)
type Image struct{
@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.
@lisamelton
lisamelton / convert-mp4-to-mkv.sh
Last active May 24, 2024 17:41
Convert MP4 video file into Matroska format without transcoding.
#!/bin/bash
#
# convert-video.sh
#
# Copyright (c) 2013-2014 Don Melton
#
about() {
cat <<EOF
$program 2.0 of December 3, 2014
package.preload['moonscript.transform.names'] = function()
local build
do
local _table_0 = require("moonscript.types")
build = _table_0.build
end
local unpack
do
local _table_0 = require("moonscript.util")
unpack = _table_0.unpack