Skip to content

Instantly share code, notes, and snippets.

View aristidb's full-sized avatar

Aristid Breitkreuz aristidb

  • Amsterdam, Netherlands
View GitHub Profile
Foo = {
// ...
}
this.load = 2
template<size_t (curl::*Method)(void *, size_t, size_t, void *)>
static size_t curl::c_handle_curl(void *ptr, size_t size, size_t nmemb, void *stream) {
curl *self = static_cast<curl*>(ptr);
return (self->*Method)(ptr, size, nmemb, stream);
}
foo ( &curl::c_handle_curl<&curl::method_name> );
suite_name = 'The big test suite'
test_foo = function() {
expect(2);
ok(1, "Check ok");
same([1,2],[3,2], "Arrays are the same");
}
/*
[execute in scope (new TestSuite)]
boost::any environment::enumerate_start(int &n) {
n = 0; // We dont know how many
return boost::any(environ);
}
value environment::enumerate_next(boost::any &iter) {
char **env = boost::any_cast<char**>(iter);
if (*env == 0)
return value();
bin/
jsrepl
lib/
libflusspferd.so
libflusspferd-xml.so
flusspferd/
prelude.js
plugins/
libxml.so -> ../../libflusspferd-xml.so
libcurl.so
buffer = require('encoding').Converter('US-ASCII', 'US-ASCII')
buffer.put(magicallyMakeByteString('Hello,'))
buffer.put(magicallyMakeByteString(' '))
buffer.put(magicallyMakeByteString('World!'))
value = buffer.get()
assert(value == magicallyMakeByteString('Hello, World!'))
buffer = require('encoding').Converter('US-ASCII', 'US-ASCII')
buffer.put(value)
assert(buffer.get(7) == magicallyMakeByteString("Hello, "))
assert(buffer.get() == magicallyMakeByteString("World!"))
@aristidb
aristidb / main.cpp
Created December 4, 2009 21:33 — forked from aq1018/main.cpp
#include <boost/spirit/home/phoenix/core.hpp>
#include <boost/spirit/home/phoenix/bind.hpp>
#include <boost/spirit/home/phoenix/operator.hpp>
#include <boost/bind.hpp>
#include "flusspferd.hpp"
using namespace flusspferd;
using namespace std;
-- | Get this amount's commodity and any commodities referenced in its price.
amountCommodities :: Amount -> [Commodity]
amountCommodities Amount{commodity=c,price=p} =
case p of Nothing -> [c]
Just (UnitPrice ma) -> c:(concatMap amountCommodities $ amounts ma)
Just (TotalPrice ma) -> c:(concatMap amountCommodities $ amounts ma)
@aristidb
aristidb / lisp.hs
Created May 1, 2011 16:35
Minimal Lisp in Haskell
{-# LANGUAGE OverloadedStrings #-}
{- To Run:
Load in ghci
:set -XOverloadedStrings (for convenience)
Execute repl expr -}
import Control.Applicative
import Data.Attoparsec hiding (Result)
import Data.Attoparsec.Char8 (char8, isDigit_w8, isSpace_w8)
@aristidb
aristidb / GameOfLife.hs
Created November 18, 2011 16:34
Conway's Game of Life in Haskell
module GameOfLife where
import Data.Set (Set, (\\))
import qualified Data.Set as S
import Data.List (intercalate)
unionMap :: (Ord a, Ord b) => (a -> Set b) -> Set a -> Set b
unionMap f = S.fromList . concatMap (S.toList . f) . S.toList