Skip to content

Instantly share code, notes, and snippets.

@ybonnel
ybonnel / twitter_say.sh
Created May 28, 2012 18:42 — forked from dgageot/twitter_say.sh
Say each tweet when it arrives
#!/bin/bash
lines_to_skip=`t timeline | wc -l | sed 's/^ *//g'`
i=0
echo Skipping [$lines_to_skip] lines in the timeline
echo From now on, say each tweet as soon as it arrives...
t stream timeline | while read -r line; do
@ybonnel
ybonnel / Singleton.java
Created July 23, 2012 06:43
Solution de Java Quiz #45 de Coder breakfast
package fr.ybo.javaquiz;
public class Singleton {
private static final Singleton INSTANCE = new Singleton();
public static Singleton getInstance() {
return INSTANCE;
}
@ybonnel
ybonnel / gist:4066133
Created November 13, 2012 14:54
Get Column names in CsvEngine
Field mapClassesField = CsvEngine.class.getDeclaredField("mapClasses");
mapClassesField.setAccessible(true);
CsvClass csvClass = ((Map<Class<?>, CsvClass>)mapClassesField.get(engine)).get(Dog.class);
System.out.println(csvClass.getColumnNames());
@ybonnel
ybonnel / CompteEstBon.java
Created January 11, 2013 09:02
Implémentation naïve du compte est bon
package fr.ybonnel.codestory;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.List;
public class CompteEstBon {
private List<Integer> listeNumbers;
@ybonnel
ybonnel / gist:4545230
Created January 16, 2013 07:09
Generateur jajascript
@Test
@Ignore
public void should_be_very_very_fast() throws IOException, SAXException {
int max = 250;
Random random = new Random();
ObjectMapper mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
WebConversation wc = new WebConversation();
for (int i =0; i < max; i++) {
List<Commande> commandes = new ArrayList<Commande>();
for (int j = 1; j <= (i+1)*5; j++) {
@ybonnel
ybonnel / expected.json
Last active December 11, 2015 06:59
Jajascript limit case
{"gain":50,"path":["0"]}
@ybonnel
ybonnel / Change.java
Created January 31, 2013 03:30
Scalaskel en java
package fr.ybonnel.codestory.path.scalaskel;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Change {
@JsonProperty
private Integer foo;
@JsonProperty
private Integer bar;
@ybonnel
ybonnel / Change.scala
Created January 31, 2013 03:35
Scalaskel en scala
package models.scalaskel
import play.api.libs.json._
import play.api.Logger
case class Change(foo:Int, bar:Int, qix:Int, baz:Int) {
def this() = this(0, 0, 0, 0)
def this(change:Change, coin:Coin) = this(
if (coin.isFoo) change.foo + 1 else change.foo,
@ybonnel
ybonnel / Scalaskel.ceylon
Created January 31, 2013 03:42
Scalaskel en ceylon
import java.util { ArrayList }
import ceylon.collection { LinkedList }
shared class Coin(Integer coinValue) {
shared Integer valeur = coinValue;
shared Boolean canPay(Integer centsToPay) {
return centsToPay >= valeur;
}
}
@ybonnel
ybonnel / bigRequestJajascript50000.json
Created January 31, 2013 04:55
Jajascript requête avec 50 000 vols
This file has been truncated, but you can view the full file.
[{"VOL":"1","DEPART":1,"DUREE":10,"PRIX":19},{"VOL":"2","DEPART":2,"DUREE":7,"PRIX":5},{"VOL":"3","DEPART":3,"DUREE":8,"PRIX":15},{"VOL":"4","DEPART":4,"DUREE":1,"PRIX":2},{"VOL":"5","DEPART":5,"DUREE":10,"PRIX":3},{"VOL":"6","DEPART":6,"DUREE":5,"PRIX":9},{"VOL":"7","DEPART":7,"DUREE":3,"PRIX":12},{"VOL":"8","DEPART":8,"DUREE":4,"PRIX":1},{"VOL":"9","DEPART":9,"DUREE":1,"PRIX":16},{"VOL":"10","DEPART":10,"DUREE":6,"PRIX":5},{"VOL":"11","DEPART":11,"DUREE":6,"PRIX":16},{"VOL":"12","DEPART":12,"DUREE":3,"PRIX":11},{"VOL":"13","DEPART":13,"DUREE":3,"PRIX":5},{"VOL":"14","DEPART":14,"DUREE":7,"PRIX":15},{"VOL":"15","DEPART":15,"DUREE":10,"PRIX":20},{"VOL":"16","DEPART":16,"DUREE":6,"PRIX":2},{"VOL":"17","DEPART":17,"DUREE":6,"PRIX":12},{"VOL":"18","DEPART":18,"DUREE":4,"PRIX":12},{"VOL":"19","DEPART":19,"DUREE":8,"PRIX":9},{"VOL":"20","DEPART":20,"DUREE":7,"PRIX":18},{"VOL":"21","DEPART":21,"DUREE":4,"PRIX":2},{"VOL":"22","DEPART":22,"DUREE":2,"PRIX":1},{"VOL":"23","DEPART":23,"DUREE":7,"PRIX":16},{"VOL":"24","D