Skip to content

Instantly share code, notes, and snippets.

View argv0's full-sized avatar

Andy Gross argv0

View GitHub Profile
@argv0
argv0 / gist:4335050
Created December 19, 2012 07:25
compile with clang++ --std=c++11 maybe.cpp
#include <cstdio>
#include <boost/optional.hpp>
template <class T>
using Maybe = boost::optional<T>;
Maybe<int> isYouPositive(int val)
{
return val > 0 ? Maybe<int>(val) : Maybe<int>();
}
#include <cstdio>
#include <stdexcept>
template <class T>
struct Maybe {
Maybe( const T& val ) : val_(val), valid_(true) { }
Maybe() : valid_(false) { }
const T& get() const {
if (valid_) return val_;
throw std::logic_error("lol type systems");
vclock_to_binary([], Acc, Size) ->
VclockSize = size(Acc),
<<VclockSize:32/integer, Acc/binary>>;
vclock_to_binary([{AId, {Count, TS}}|T], Acc, Size) ->
AIdSize = size(AId),
vclock_to_binary(T, <<AIdSize:8/integer, AId:AIdSize/binary, Count:64/integer, TS:32/integer, Acc/binary>>, Size+1).
binary_to_vclock(<<VclockSize:32/integer, VclockBin:VclockSize/binary, Rest/binary>>) ->
binary_to_vclock(VclockBin, []).
AC_DEFUN([AC_HEADER_SHARED_PTR], [
AC_CACHE_CHECK(for tr1/shared_ptr,
ac_cv_cxx_tr1_shared_ptr,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([#include <tr1/memory>], [using std::tr1::shared_ptr;],
ac_cv_cxx_tr1_shared_ptr=yes, ac_cv_cxx_tr1_shared_ptr=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_tr1_shared_ptr" = yes; then
@argv0
argv0 / gist:3627514
Created September 4, 2012 22:35
Markov Chain Thing I Wrote A Long Time Ago
import random, sys
NONWORD = "\n"
STARTKEY = NONWORD, NONWORD
MAXGEN=1000
class MarkovChainer(object):
def __init__(self):
self.state = dict()
@argv0
argv0 / gist:3372596
Created August 16, 2012 18:49
Getting detailed per-request timing in Riak
(riak@127.0.0.1)1> {ok, C} = riak:local_client().
{ok,{riak_client,'riak@127.0.0.1',undefined}}
(riak@127.0.0.1)2> Object = riak_object:new(<<"testbucket">>, <<"testkey">>, <<"testvalue">>).
{r_object,<<"testbucket">>,<<"testkey">>,
[{r_content,{dict,0,16,16,8,80,48,
{[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
{{[],[],[],[],[],[],[],[],[],[],[],[],...}}},
<<"testvalue">>}],
[],
{dict,1,16,16,8,80,48,
PCAP error: 'truncated dump file; tried to read 973 captured bytes, only got 61'
5316395 packets seen, 5316395 TCP packets traced
elapsed wallclock time: 0:06:39.340798, 13312 pkts/sec analyzed
trace file elapsed time: 0:07:29.206448
TCP connection info:
1 TCP connection traced:
TCP connection 1:
host a: 17.154.234.156:43011
host b: 17.173.26.148:8010
complete conn: no (SYNs: 2) (FINs: 0)
Subject: /var/hg/repos/webmachine: testing notify hook
From: hg-commit@basho-1.argv0.net
To: andy@andygross.org
Date: Thu, 17 Jan 2008 20:59:17 +0000
details: https://basho-1.argv0.net/hg//var/hg/repos/webmachine/rev/c39a5a60ba01
changeset: 115:c39a5a60ba01
user: andy@thedude.local
date: Thu Jan 17 15:59:13 2008 -0500
description:
@argv0
argv0 / couchbase_prospecting_fail
Created December 29, 2011 06:30
sales is a art
Date: Wed, 28 Dec 2011 18:16:57 +0000 (GMT)
From: Jordan Vandenberg <jordan@couchbase.com>
To: "andy@basho.com" <andy@basho.com>
Subject: Couchbase NoSQL @ Basho Technologies
Hi Andy,
Thanks for your interest in Couchbase. A NoSQL database could help Basho Technologies create a fast, scalable data tier.
(setq erlang-root-dir "/usr/local/lib/erlang")
(setq load-path (cons "/usr/local/lib/erlang/lib/tools-2.6.6.5/emacs" load-path))
(setq load-path (cons "/Users/andy/.elisp" load-path))
(setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path))
(require 'column-marker)
;; Local el path
(setq indent-tabs-mode nil)
(setq-default indent-tabs-mode nil)