Skip to content

Instantly share code, notes, and snippets.

View larroy's full-sized avatar
🎧
In the zone

Pedro Larroy larroy

🎧
In the zone
View GitHub Profile
@joa
joa / go.scala
Created June 1, 2011 11:12
Go Channels in Scala
package go
import java.util.concurrent.{
BlockingQueue => JBlockingQueue,
ArrayBlockingQueue => JArrayBlockingQueue
}
object Channel {
def empty[A]: Channel[A] = new BlockingChannel()
def make[A]: Channel[A] = make(1)
@usagi
usagi / boost_geometry_index_rtree.cpp
Created August 18, 2011 11:11
R-Tree sample using boost::geometry::index::rtree
#include <boost/geometry.hpp>
#include <boost/geometry/extensions/index/rtree/rtree.hpp>
#include <random>
#include <iostream>
#include <exception>
int main() try{

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@kohlmeier
kohlmeier / ka_bnet_numpy.py
Created March 26, 2012 21:59
Bayes net example in Python with Khan Academy data
#!/usr/bin/env python
from numpy import asmatrix, asarray, ones, zeros, mean, sum, arange, prod, dot, loadtxt
from numpy.random import random, randint
import pickle
MISSING_VALUE = -1 # a constant I will use to denote missing integer values
def impute_hidden_node(E, I, theta, sample_hidden):
@ogrant
ogrant / has_callable.cpp
Created April 1, 2012 15:29
C++11 Metaprogramming - Traits to check whether a function with a specific name can be called in the context defined by a signature
// Here is a traits structure I wrote to be able to determine if a function with
// a given name can be called in the context defined by a signature. This was
// originally not possible in C++03 - or at least a one solution works everywhere
// did not exist AFAIK.
//
// Olivier Grant
//
#include <iostream>
#include <iomanip>
@dln
dln / inotify-cmake.sh
Created July 17, 2012 10:36
Continuous build on the cheap, using inotify, cmake and a terminal
#!/bin/bash
# Watch paths (given as arguments), automatically build when something changes.
# The script does a couple opinionated things to make my life easier:
#
# * Terminal scrollbuffer is reset before each iteration, simplifying scrolling.
# * I use a filter script to colorize gcc output (clang errors would be nicer).
# * Output is copied to a log file (/tmp/build.log).
# - I open this file in Sublime or vim, which reloads the file on change (each build).
#
# Usage:
@josiahcarlson
josiahcarlson / chunked_server_test.py
Last active March 20, 2024 20:30
Use some standard Python libraries to implement a chunked-transfer encoding web server with partially-working gzip support
'''
chunked_server_test.py
Copyright August 3, 2012
Released into the public domain
This implements a chunked server using Python threads and the built-in
BaseHTTPServer module. Enable gzip compression at your own peril - web
browsers seem to have issues, though wget, curl, Python's urllib2, my own
async_http library, and other command-line tools have no problems.
@tubaman
tubaman / worker.py
Last active October 9, 2015 13:28
Disco worker that zips up imported modules/packages
#!/usr/bin/env python
"""Disco worker that automatically finds and sends to the nodes all the modules and packages that are used"""
import os
import sys
import shutil
import tempfile
import zipfile
import modulefinder
from inspect import getsourcefile, getmodule
@roxlu
roxlu / SSLBuffer.cpp
Created November 2, 2012 11:38
libuv + openssl + SSLBuffer
#include "SSLBuffer.h"
SSLBuffer::SSLBuffer()
:ssl(NULL)
,read_bio(NULL)
,write_bio(NULL)
,write_to_socket_callback(NULL)
,write_to_socket_callback_data(NULL)
,read_decrypted_callback(NULL)
,read_decrypted_callback_data(NULL)
@mkuklis
mkuklis / gist:5294248
Last active September 7, 2021 21:39
auto curry in JavaScript
function toArray(args) {
return [].slice.call(args);
}
function autocurry(fn) {
var len = fn.length;
var args = [];
return function next() {
args = args.concat(toArray(arguments));
return (args.length >= len) ?