Skip to content

Instantly share code, notes, and snippets.

View aristidb's full-sized avatar

Aristid Breitkreuz aristidb

  • Amsterdam, Netherlands
View GitHub Profile
(gdb) run -f doc/sample.dat bal
Starting program: /home/aristid/Code/ledger/build/ledger/debug/ledger -f doc/sample.dat bal
[Thread debugging using libthread_db enabled]
Catchpoint 1 (exception thrown), 0x00e27525 in __cxa_throw () from /usr/lib/libstdc++.so.6
(gdb) bt
#0 0x00e27525 in __cxa_throw () from /usr/lib/libstdc++.so.6
#1 0x082882e5 in ledger::throw_func<ledger::date_error> (message=...) at /home/aristid/Code/ledger/src/error.h:55
#2 0x08280a83 in ledger::date_parser_t::lexer_t::token_t::expected (wanted=0 '\000', c=77 'M') at /home/aristid/Code/ledger/src/times.cc:1440
#3 0x082804ad in ledger::date_parser_t::lexer_t::next_token (this=0xbfffbfb8) at /home/aristid/Code/ledger/src/times.cc:1411
#4 0x0827820a in ledger::date_parser_t::parse (this=0xbfffbfb4) at /home/aristid/Code/ledger/src/times.cc:676
$ ledger -f tests/ordering.ledger bal
10 EUR Aktiva:Bargeld
0 Passiva
-10 EUR Anfangsbestand
--------------------
0
@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;
# Für jedes Spiel kann ein Tipp abgegeben werden. Man kann auch nur selektiv Spiele tippen.
# Ab dem Achtelfinale können zusätzlich auch die Mannschaften getippt werden.
# Beachte: Ersetze nur die jeweiligen '-' mit Deinen Tipps. Unlesbare Datensätze werden ignoriert.
Spiel 1: Südafrika versus Mexiko: Tipp: (1:2)
Spiel 2: Uruguay versus Frankreich: Tipp: (2:1)
Spiel 3: Argentinien versus Nigeria: Tipp: (1:2)
Spiel 4: Korea Republik versus Griechenland: Tipp: (2:1)
Spiel 5: England versus USA: Tipp: (3:3)
Spiel 6: Algerien versus Slowenien: Tipp: (0:1)
//******************************************************************************
// MSP430F20xx Demo - Timer_A, Ultra-Low Pwr UART 2400 Echo, 32kHz ACLK
//
// Description: Use Timer_A CCR0 hardware output modes and SCCI data latch
// to implement UART function @ 2400 baud. Software does not directly read and
// write to RX and TX pins, instead proper use of output modes and SCCI data
// latch are demonstrated. Use of these hardware features eliminates ISR
// latency effects as hardware insures that output and input bit latching and
// timing are perfectly synchronised with Timer_A regardless of other
// software activity. In the Mainloop the UART function readies the UART to
-- | 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 / gist:1270845
Created October 7, 2011 17:22
Code to generate list permutations
import Data.Tree
import Data.List
import Control.Applicative
permutationForest :: [a] -> Forest a
permutationForest = zipWith3 build <*> inits <*> tail . tails
where build a xs ys = Node a (permutationForest $ xs ++ ys)
traverse :: Forest a -> [[a]]
traverse [] = [[]]
@aristidb
aristidb / spark.hs
Created November 15, 2011 19:41
Slightly changed version
-- Generate a sparkline, Haskell version of <https://github.com/holman/spark/>
-- Usage: after compile, try '$ spark -10 0 15.24 42'
-- Author: Chao Xu, <http://chaoxuprime.com>
import System (getArgs)
main :: IO ()
main = do input <- getArgs
putStrLn $ spark (map read input :: [Double])
spark :: RealFrac b => [b] -> String
@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