Skip to content

Instantly share code, notes, and snippets.

View argv0's full-sized avatar

Andy Gross argv0

View GitHub Profile
@argv0
argv0 / gist:7548792
Last active December 28, 2015 19:18
#include <mutex>
#include <thread>
#include <async>
using namespace std;
template <typename T>
struct locked_queue
{
typedef lock_guard<mutex> lock_guard;
#include <map>
#include <vector>
#include <string>
#include <future>
#include <numeric>
#include <iterator>
#include <boost/lexical_cast.hpp>
using namespace std;
using boost::lexical_cast;
@argv0
argv0 / gist:7309435
Last active December 27, 2015 10:09
#include <map>
#include <vector>
#include <string>
#include <future>
#include <boost/lexical_cast.hpp>
using namespace std;
using boost::lexical_cast;
typedef map<string, string> object;
struct echo_service
{
struct handler : public handler_base
{
handler(ip::tcp::socket& socket) : handler_base(socket) {}
void handle_data(const std::string& readbuf)
{
io::async_write(socket_, buffer(readbuf), ignore());
}
#include <cstdlib>
#include <iostream>
#include <boost/coroutine/all.hpp>
using namespace boost::coroutines;
using namespace std;
int main()
{
coroutine< int() > c(
@argv0
argv0 / fibonacci.cpp
Last active December 25, 2015 20:59
one can do some crazy stuff with c++11 and boost
#include <cstdlib>
#include <iostream>
#include <boost/coroutine/all.hpp>
using namespace boost::coroutines;
using namespace std;
int main()
{
coroutine< int() > c(
@argv0
argv0 / gist:6835711
Created October 5, 2013 02:02
whatchu know about massively simpler riak configuration
## The enabled Yokozuna set this 'on'.
yokozuna = off
## The port number which Solr binds to.
yokozuna.solr_port = 8093
## The port number which Solr JMX binds to.
yokozuna.solr_jmx_port = 8985
## The arguments to pass to the Solr JVM. Non-standard
simple_test() ->
{ok, EC} = erasuerl:new(),
{ok, Bin} = file:read_file("/usr/share/dict/words"),
{MD, KBins, MBins} = erasuerl:encode(EC, Bin),
[K1, K2, K3, K4, K5, K6, K7, K8, K9] = KBins,
[M1, M2, M3, M4] = MBins,
KBins2 = [undefined, undefined, undefined, K4, K5, K6, K7, K8, K9],
MBins2 = [undefined, M2, M3, M4],
Bin = iolist_to_binary(erasuerl:decode(EC, MD, KBins2, MBins2)).
➜ riak git:(jrw-dynamic-ring) ✗ bin/riak-admin cluster resize-ring 128
Success: staged resize ring request with new size: 128
➜ riak git:(jrw-dynamic-ring) ✗ bin/riak-admin cluster plan
=============================== Staged Changes ================================
Action Details(s)
-------------------------------------------------------------------------------
resize-ring 64 to 128 partitions
-------------------------------------------------------------------------------
import Data.List
myalist = [("foo", (1, 2))]
getFirst :: String -> [(String, (Int, Int))] -> Maybe Int
getFirst key alist = fmap fst $ lookup key alist
-- shouldn't this work?
getFirst' :: String -> [(String, (Int, Int))] -> Maybe Int