Skip to content

Instantly share code, notes, and snippets.

View dgageot's full-sized avatar

David Gageot dgageot

View GitHub Profile
@dgageot
dgageot / FindParametersTypes.java
Created August 19, 2014 10:03
Find Lambda parameter types
package test;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import java.util.function.Function;
import static java.util.stream.Stream.of;
public class FindParametersTypes {
@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 / MergedIterator.java
Last active December 5, 2020 13:54
Merged Iterator. Uses Guava
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.NoSuchElementException;
import com.google.common.collect.Iterators;
import com.google.common.collect.PeekingIterator;
public class MergedIterator<T> implements Iterator<T> {
private final Comparator<? super T> comparator;
@dgageot
dgageot / draft_billet_macos.md
Created October 31, 2010 08:22
Installation git sous OSX

MacOS est un Unix, et à ce titre, l'installation de git n'est pas trop compliqué :). Pour résumé, vous avez 2 méthodes :

  • installer une version déjà compilée par un tiers
  • installer une version source

Cette dernière méthode est plus contraignante, votre système doit contenir le nécessaire pour compiler (compilateur GCC, outil Make et Autoconf...). Les utilisateurs d'Unix libres (Linux, *BSD) ne seront pas étonnés par ces 2 méthodes d'installation.

Installer une version compilée

Pour ceux qui souhaitent ne pas "se prendre la tête", Il existe le projet Git OSX Installer, qui permet d'installer simplement git sur Mac OS X 10.5 uniquement. Vous pouvez constater que le projet est actif (au 30/11/2010, la version 1.7.3.1 est disponible alors que la dernière version est la 1.7.3.2).

@dgageot
dgageot / PhantomJsDownloader.java
Last active May 28, 2019 17:40
PhantomJs / GhostDriver / FluentLenium with automatic install of PhantomJs
package com.fractales.synchro.helpers.phantomjs;
import com.google.common.io.ByteStreams;
import com.google.common.io.Files;
import com.google.common.io.InputSupplier;
import com.google.common.io.OutputSupplier;
import com.google.common.io.Resources;
import java.io.File;
import java.io.FileOutputStream;
[alias]
wip = !"git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m \"wip\""
unwip = !"git log -n 1 | grep -q -c wip && git reset HEAD~1"
rb = !"git wip;git rebase -i origin/master;git unwip"
pr = !"git fetch;git wip;git rebase --stat origin;git unwip;git heads"
head = !"git log -n1"
lost = !"git fsck | awk '/dangling commit/ {print $3}' | git show --format='SHA1: %C(yellow)%h%Creset %f' --stdin | awk '/SHA1/ {sub(\"SHA1: \", \"\"); print}'"
heads = !"git log origin/master.. --format='%Cred%h%Creset;%C(yellow)%an%Creset;%H;%Cblue%f%Creset' | git name-rev --stdin --always --name-only | column -t -s';'"
package main
import (
"archive/tar"
"fmt"
"io"
"log"
"os"
tartar "github.com/vbatts/tar-split/archive/tar"
@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 / Types.java
Created June 22, 2013 08:57
Oops, a Lambda tends to forget what's its type.
public class Types {
interface SMI<T> {
T get(T value);
}
public static void main(String[] args) {
SMI<String> inner = new SMI<String>() {
@Override
public String get(String param) {
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0