Skip to content

Instantly share code, notes, and snippets.

View fbiville's full-sized avatar

Florent Biville fbiville

View GitHub Profile
@fbiville
fbiville / gist:1306553
Created October 22, 2011 22:16
wmctrl makes your mornings easier
#!/bin/bash
# force 8 workspaces
wmctrl -n 8
# launch
eclipse &
firefox -P default &
thunderbird &
amsn &
@fbiville
fbiville / update
Created May 15, 2012 08:14
Tiny snippet to update Git projects contained in the same directory.
#!/bin/bash
git_pull () {
echo ""
echo "## Updating $1 ##"
echo ""
cd $1
git pull
cd - > /dev/null
}
@Test
public void when_plain_text_then_equal_text_returned() {
assertThat(markupKiller.stripTags("10 < 9")).isEqualTo("10 < 9");
}
@Test
public void when_unbalanced_html_then_markup_removed() {
assertThat(markupKiller.stripTags("<b>10 < 9")).isEqualTo("10 < 9");
assertThat(markupKiller.stripTags("<b id='whatever'>10 < 9<img />")).isEqualTo("10 < 9");
}
@fbiville
fbiville / ZuperDao
Last active December 12, 2015 05:48
Refactoring puzzler: how to remove duplication here?
StringBuilder whereConstraints = new StringBuilder();
if (!isEmpty(typesActu)) {
whereConstraints.append(" AND a.type_id IN (?) ");
}
if (!isEmpty(newsletters)) {
whereConstraints.append(" AND (ap.profils_id IN (?) OR ap.profils_id IS NULL)");
}
if (!isNullOrEmpty(term)) {
whereConstraints.append(" AND (titre LIKE (?) OR texte_complet LIKE(?) ) ");
}
@fbiville
fbiville / xn
Last active December 17, 2015 11:09
Send notification after your build is done. Example (with oh-my-zsh plugin alias): xn mvnci
#!/bin/zsh
source /home/fbiville/.zshrc
if [[ -z "$@" ]]; then
echo "ERROR: specify a nonempty command"
else
eval "$@"; notify-send "`pwd`: command finished"
fi
#!/bin/zsh
sed ''/$1/s//`printf "\033[1;32m$1\033[0m"`/''
@fbiville
fbiville / DijkstraTest.java
Created August 11, 2013 10:41
Week 5 - simple test cases
package com.github.fbiville.coursera.algorithmics_stanford.week5;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.util.Lists.newArrayList;
import org.testng.annotations.Test;
import com.google.common.collect.Lists;
public class DijkstraTest {
@fbiville
fbiville / recommendations.cypher
Created October 27, 2013 15:10
Exemple de graphe social professionnel.
Example CREATE (flo:CONTACT {name: 'Florent'}) RETURN flo;
CREATE (eric:CONTACT {name: 'Eric'}) RETURN eric;
CREATE (jb:CONTACT {name: 'Jean-Baptiste'}) RETURN jb;
CREATE (samuel:CONTACT {name: 'Samuel'}) RETURN samuel;
CREATE (meta:COMPANY {name: 'Metaboli'}) RETURN meta;
CREATE (lt:COMPANY {name: 'Lateral Thoughts'}) RETURN lt;
// -- Florent worked for Metaboli
MATCH (flo:CONTACT), (meta:COMPANY)
@fbiville
fbiville / Vidal.cypher
Last active December 31, 2015 13:29
VIDAL GraphGist
CREATE (p:PATIENT {firstName:"Robert", lastName:"Patraque"}) RETURN p;
CREATE (p:PATIENT {firstName:"Chantale", lastName:"Tristoune"}) RETURN p;
CREATE (s:SYMPTOM {name:"Écoulement nasal"}) RETURN s;
CREATE (s:SYMPTOM {name:"Fièvre"}) RETURN s;
CREATE (s:SYMPTOM {name:"Éructations"}) RETURN s;
CREATE (s:SYMPTOM {name:"Flatulences"}) RETURN s;
CREATE (s:SYMPTOM {name:"Vomissement"}) RETURN s;
@fbiville
fbiville / aggregator.js
Created January 4, 2014 10:07
Custom feed aggregator. Stack: requirejs (+text.js)+underscore+async+moment.js+jquery+handlebars
define( ['jquery', 'underscore', 'async', 'moment', 'Handlebars'],
function($, _, async, moment, Handlebars) {
var crossOriginFeedParserUrl = function(limit, feedUrl) {
return document.location.protocol +
'//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num='+
limit+
'&callback=?&q=' +
encodeURIComponent(feedUrl);
},