Skip to content

Instantly share code, notes, and snippets.

View dgageot's full-sized avatar

David Gageot dgageot

View GitHub Profile
@dgageot
dgageot / CodeStoryStatusTest.java
Last active November 4, 2021 10:20
FluentLenium, PhantomJs, GhostDriver
package net.gageot;
import org.junit.Test;
import static org.fest.assertions.Assertions.assertThat;
public class CodeStoryStatusTest extends PhantomJsTest {
@Override
public String defaultUrl() {
return "http://status.code-story.net";
@dgageot
dgageot / PhantomJsTest.java
Created February 5, 2013 16:14
Exemple de test avec FluentLenium et ZombieJs
package net.gageot;
import org.junit.Test;
import static org.fest.assertions.Assertions.assertThat;
public class PhantomJsTest extends AbstractPhantomJsTest {
public String defaultUrl() {
return "http://www.bing.com";
}
@dgageot
dgageot / AbstractPhantomJsTest.java
Created February 5, 2013 15:32
Bridge FluentLenium and PhantomJS. Makes sure PhantomJs is started only once
package net.gageot;
import org.fluentlenium.core.FluentAdapter;
import org.junit.AfterClass;
import org.junit.Before;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.service.DriverService;
@dgageot
dgageot / twitter_say.sh
Created May 16, 2012 15:05
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
@dgageot
dgageot / git-build
Created May 16, 2012 08:12
Unbreakeable build
#!/bin/bash
function alert_user {
echo "${1}"
which -s growlnotify && growlnotify `basename $0` -m "${1}"
}
function exit_ko {
alert_user "${1}"; exit 1
}
@dgageot
dgageot / ItemUpdater.java
Created February 9, 2012 19:29
Gilde Rose en 12 lignes....
package fr.xebia.katas.gildedrose;
@lombok.AllArgsConstructor
class ItemUpdater {
@lombok.Delegate Item item;
void updateQuality() {
setSellIn(getSellIn() - ("Sulfuras, Hand of Ragnaros".equals(getName()) ? 0 : (("Aged Brie".equals(getName()) && updateQuality(getQuality() + 1 + (getSellIn() <= 0 ? 1 : 0))) || ("Backstage passes to a TAFKAL80ETC concert".equals(getName()) && updateQuality(getSellIn() <= 0 ? 0 : (getQuality() + 1 + (getSellIn() <= 10 ? 1 : 0) + (getSellIn() <= 5 ? 1 : 0)))) || ("Conjured Mana Cake".equals(getName()) && updateQuality(getQuality() - 2 - (getSellIn() <= 0 ? 2 : 0))) || updateQuality(getQuality() - 1 - (getSellIn() <= 0 ? 1 : 0)) ? 1 : 1)));
}
@dgageot
dgageot / foobarqix.ik
Created December 22, 2011 13:13
FooBarQix
Origin replaceDigit = method(case(self,
or(3,"3"), "Foo",
or(5,"5"), "Bar",
or(7,"7"), "Qix",
""
))
forMultiples = fn(n,
[3,5,7] filter(div, (n%div) == 0) map(replaceDigit)
)
@dgageot
dgageot / sierpinski.ik
Created December 20, 2011 18:08
sierpinski
use("ispec")
iter = method(chars,height,offY,offX,
(height == 1) ifTrue(
chars[offY][offX] = "\u25B2",
) ifFalse(
height /= 2
iter(chars,height,offY+height,offX-height)
iter(chars,height,offY,offX)
iter(chars,height,offY+height,offX+height)
@dgageot
dgageot / auizz.ik
Created October 31, 2011 18:48
Coding challenge (updated)
;Response to challenge at http://beust.com/weblog/2011/10/30/a-new-coding-challenge/
N = 40
combinations = for(
a <- 1..N-3,
b <- a..N-3,
c <- b..N-3,
d <- c..N-3,
a+b+c+d == N,
@dgageot
dgageot / watchr.config
Created May 5, 2011 21:43
Continuous testing on iOS dev
# sudo gem install watchr growl
#
# Run me with:
# $ watchr watch.txt
#
require 'growl'
watch('.*\.m') {test}
watch('.*\.h') {test}
watch('IpadCorporate.xcodeproj/.*') {test}