Skip to content

Instantly share code, notes, and snippets.

class Scenario[T <: ScenarioContext[T]](val title: String)(implicit val context : T) {
import system._
private var s: Scenario[T] = null
def apply(synopsis: => Unit) = {
new Scenario(title)(context) {
override def run : Unit = synopsis
}
@abailly
abailly / util.cpp
Created April 9, 2011 07:50
trim and tokenize
using namespace std;
vector<string> tokenize(string const &line, char separator) {
vector<string> tokens;
istringstream elements(line);
while(!elements.eof()) {
string token;
getline(elements, token, separator);
tokens.push_back(token);
}
@abailly
abailly / Main.hs
Created February 1, 2012 13:42
sound module
import System.Environment (getArgs)
import qualified Data.ByteString.Lazy as B
import Sound
outputSound = B.putStr.B.pack.map fromIntegral.scale (0,255)
main = do
[frequency,volume,duration] <- getArgs
let f = read frequency :: Int
let d = read duration :: Int
@abailly
abailly / gist:1948301
Created March 1, 2012 08:24
battle language sample
import Control.Monad
import Data.List
-- http://xkcd.com/287/
-- On voudrait pour 15.05 € de tapas; SVP
menu = [("gambas" ,215),
("aceitunas" ,275),
("choquitos" ,335),
("empanada" ,355),
@abailly
abailly / cmd
Created March 8, 2012 08:04
Code from OpaDevCamp #1
opa test.opa hello.opa --database mongo
@abailly
abailly / YakGraph.hs
Created January 30, 2013 21:28
File failing to compile with package conflicts
module YakGraph(listOfClusterNames, listOfNodesPerCluster, countOfNodesPerCluster) where
import Data.GraphViz.Types
import Data.GraphViz.Types.Graph
import Data.GraphViz.Commands.IO
import qualified Data.Map as M
import Data.List(groupBy)
import Data.Maybe
import Data.Text.Lazy(unpack)
import Data.Sequence(Seq)
import Data.Foldable(toList)
@abailly
abailly / gist:5826206
Created June 20, 2013 20:14
Possible use of Locatable to add source information to parsers
public class AnnotatedASTParserTest {
//~ ----------------------------------------------------------------------------------------------------------------
//~ Methods
//~ ----------------------------------------------------------------------------------------------------------------
@Test
public void canProduceAnASTWithSourceForEachNode() throws Exception {
Parser<?> lparen = Scanners.isChar('(');
Parser<?> rparen = Scanners.isChar(')');
@abailly
abailly / gist:6231966
Created August 14, 2013 15:09
Tracing parser
public final class Productions {
//~ ----------------------------------------------------------------------------------------------------------------
//~ Static fields/initializers
//~ ----------------------------------------------------------------------------------------------------------------
private static final Logger DEFAULT_LOGGER = Logger.getLogger(Productions.class.getName());
//~ ----------------------------------------------------------------------------------------------------------------
//~ Constructors
@abailly
abailly / gist:6607111
Last active December 23, 2015 08:19
Some stats on education DE, FR, UK

source: Eurostat

Enrollment per country (Level 0-3) 2011:

  • European Union (27 countries) 86 622 125
  • Germany (until 1990 former territory of the FRG) 12 902 834
  • France 12 619 699
  • United Kingdom 11 748 541

Teachers per country (Level 0-3) 2011:

@abailly
abailly / gist:8848689
Created February 6, 2014 17:23
code story ne build pas sous windows 7 + jdk8
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building CodeStory - Http Server 1.29-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ http ---
[INFO] Deleting d:\projects\code-story-http\target
[INFO]
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ http ---