Skip to content

Instantly share code, notes, and snippets.

# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
@kevsmith
kevsmith / example.erl
Created September 12, 2011 14:14
Example of gen_server template output
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et
%% @author Kevin Smith <kevin@opscode.com>
%% @copyright 2011 Opscode, Inc.
-module(example).
-behaviour(gen_server).
-export([start_link/0]).
@mads-hartmann
mads-hartmann / demystify_state_monad.hs
Created September 21, 2011 21:26
This is an attempt to de-mystify how Control.Monad.State.get seems to magically create a State out of nothing.
{-
Dear reader,
This is an attempt to de-mystify how Control.Monad.State.get seems to
magically create a State out of nothing.
Here's an example taken from the documentation:
tick :: State Int Int
tick = do
@fbettag
fbettag / gist:1238877
Created September 24, 2011 02:33
difference between no caching and MY caching ;)
fbettag@home .oO(~) $ siege -b http://172.16.1.5:8080/
** SIEGE 2.70
** Preparing 25 concurrent users for battle.
The server is now under siege...^C
Lifting the server siege... done.
Transactions: 977 hits
Availability: 100.00 %
Elapsed time: 11.40 secs
Data transferred: 2.97 MB
Response time: 0.29 secs
@jbpotonnier
jbpotonnier / GroupBy.hs
Created October 24, 2011 21:38
groupBy in Erlang and Haskell
module GroupBy where
import Data.Map (Map)
import qualified Data.Map as Map
groupBy :: Ord b => (a -> b) -> [a] -> Map b [a]
groupBy f = foldr (\ v -> Map.insertWith (++) (f v) [v]) Map.empty
groupBy' :: Ord b => (a -> b) -> [a] -> Map b [a]
@philtomson
philtomson / puzzle.ml
Created March 3, 2012 20:30
Solve a puzzle posed on NPR (see: http://www.npr.org/2012/01/29/146034893/this-puzzle-is-the-pits - "Next Week" section )
(* Inspired by this puzzle from NPR:
http://www.npr.org/2012/01/29/146034893/this-puzzle-is-the-pits
(see the 'Next Weeks' challenge section there):
"Next Week's Challenge from listener Ed Pegg Jr.: Write the digits from
1 to 9 in a line. If you put times signs after the 2 and 4, a plus
sign after the 5, and a minus sign after the 7, you have
12 x 34 x 5 + 67 - 89, which equals 2018.
That's six years off from our current year 2012. This example uses
four arithmetic symbols. The object is to use just three of the
following arithmetic operations: addition, subtraction, multiplication
@SteveSongMIT
SteveSongMIT / captainflint.dtl
Created March 20, 2012 22:50
Simple Cowboy web server + ErlyDTL
<html>
<body>
GET squawk:<br />
{{ squawk_get }}<br /><br />
POST squawk:<br />
{{ squawk_post }}<br /><br />
@tjweir
tjweir / gist:3437067
Created August 23, 2012 14:18 — forked from timperrett/gist:3436334
reader monad for java.util.Properties example
/* Start by creating a reader for some fake yet conceivable type for executing SQL queries. */
val dbReader: Reader[Properties, JdbcExecutor] =
for {
driver <- read[String]("db.driver")
uri <- read[String]("db.uri")
user <- read[String]("db.username")
password <- read[String]("db.password")
name <- read[String]("db.pool.name")
minCons <- read[Int]("db.pool.minConnections")
@lukego
lukego / gist:3952159
Created October 25, 2012 11:46
Erlang literate programming
Simple literate programming.
Add comments to your Erlang file with a special %%% syntax, like this:
%%% This is a comment that will be formatted in a variable width font with Markdown.
%%% You can use *emphasis* and
%%% # Headings
%%% and even
%%%
%%% - Lists
@jdegoes
jdegoes / DataScienceInScala.scala
Created February 8, 2013 15:11
Example code for the Creating a Data Science Platform in Scala talk.
object BenchmarkCommon {
import scala.util.Random
val DatasetSize = 10000
val Iterations = 10000
val ArrayPoolSize = 1000
val ArrayPool = {
def randomArray(): Array[Int] = {
val array = new Array[Int](DatasetSize)