Skip to content

Instantly share code, notes, and snippets.

html,body,div,p{margin:0;padding:0;border:0;}
.dp20,.dp25,.dp33,.dp50,.dp100{float:left;display:inline;*margin-left:-0.04em;}
.dp20{width:20%;}
.dp25{width:25%;}
.dp33{width:33.33%;}
def append(e, l = []):
l.append(e)
return l
tmp0 = append("what")
tmp1 = append("the")
tmp2 = append("fuck")
print tmp2 # → ['what', 'the', 'fuck']
typedef union _zvalue_value {
long lval; /* long value */
double dval; /* double value */
struct {
char *val;
int len;
} str;
HashTable *ht; /* hash table value */
zend_object_value obj;
-module(server).
-export([start/0]).
% 1 - Download and install Mochiweb, make sure it is in the ebin path (-pa).
% 2 - Run with server:start()
% 3 - Point you browser to http://127.0.0.1:12345/something
% 4 - A primitive benchmark: "ab -c 1000 -n 10000 http://127.0.0.1:12345/test"
start() ->
Options = [
import scala.actors.Actor
import scala.actors.Actor._
case class Inc(amount: Int)
case class Value
class Counter extends Actor {
var counter: Int = 0;
def act() = {
module Main where
import Control.Concurrent
import Control.Exception
import System.IO.Unsafe
proc :: MVar Int -> IO ()
proc m = do
v <- takeMVar m
-module(counter_with_locks).
-compile(export_all).
start_counter() ->
Pid = spawn(?MODULE, counter_loop, [0]),
register(counter, Pid).
counter_loop(N) ->
receive
-module(counter_with_retry).
-compile(export_all).
start_counter() ->
Pid = spawn(?MODULE, counter_loop, [0]),
register(counter, Pid).
counter_loop(N) ->
receive
module Main where
import Control.Monad.Writer
import System(getArgs, getProgName)
data Column = LeftCol | MiddleCol | RightCol
-- describe the move of one block from column src to column dst
describeMove :: Int -> Column -> Column -> Writer String ()
describeMove object src dst = do
/**
* g++ `llvm-config --cxxflags` -c -o test.o test.cpp
* g++ -o test `llvm-config --ldflags --libs` test.o
*/
#include "llvm/Module.h"
#include "llvm/Instructions.h"
#include "llvm/ModuleProvider.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/ExecutionEngine/JIT.h"