Skip to content

Instantly share code, notes, and snippets.


Eric Bouchut ebouchut

View GitHub Profile
ebouchut / disable_postgres_autostart_on_macos
Created April 16, 2014 08:42
Disable Postgres (installed with Homebrew) autostart on MacOS
View disable_postgres_autostart_on_macos
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
ebouchut / git_ref_to_sha1
Created January 15, 2013 15:44
git SHA1 to reference name conversion (back and forth)
View git_ref_to_sha1
git rev-parse: RefName ======> SHA1
git name-rev: SHA1 <===== RefName
# Convert the reference name HEAD to its corresponding SHA1
git rev-parse HEAD # Assuming for the sake of example that it outputs 1234567
# Convert the SHA1 (1234567) into its reference name (should output HEAD in our example)
git name-rev 1234567
# or else
ebouchut / LighttpdReverseProxyURLRewriting
Last active January 27, 2021 20:35
Lighttpd reverse-proxy to that matches an URL _and_ does URL rewriting #web #server #lighttpd
View LighttpdReverseProxyURLRewriting
#server.modules += ( "mod_rewrite")
# Workaround to have a working reverse-proxy that matches an URL does URL rewriting in Ligghtpd.
# Ligtthpd 1.4.28 cannot perform both matching and URL rewriting at the same time.
# Therefore we need to define 2 proxies, one does the matching and bounce the request
# to the other one, in charge of rewriting the URL before proxying the request to the target server.
# More about this here:
ebouchut / WhereDoesMavenDependencyComesFrom
Last active November 25, 2020 10:09
How to check where a maven dependency comes from #maven #find #dependency
View WhereDoesMavenDependencyComesFrom
# To check from where a maven dependency comes from
mvn dependency:tree -Dincludes=groupId:artifactId
ebouchut /
Last active October 6, 2019 14:52
Format a Java Date as UTC String: yyyy-mm-dd HH:mm:ss'Z'
publicString formatDateAsUTC(Date date) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'Z'");
return sdf.format(date);
ebouchut / set_SQL_sequence.sql
Last active July 29, 2019 14:23
Set SQL sequence
View set_SQL_sequence.sql
-- reset sequence to the max value of its ids
SELECT setval('public.mytable_id_seq', (SELECT MAX(id) FROM mytable));
-- get the last value of a sequence
SELECT last_value FROM mytable_id_seq;
ebouchut / multi_cherry_pick
Created August 16, 2012 12:21
Cherry pick multiple commits
View multi_cherry_pick
Cherry pick the commits from a through z (assuming SHA1 a is older than z)
git rev-list --reverse --topo-order a^..z | xargs -n 1 git cherry-pick
The below code does not work as it will squash all the commits (a..z) in a single one.
git cherry-pick a..z
ebouchut / solarized-dark.css
Created February 7, 2017 14:44 — forked from qguv/solarized-dark.css
Solarized theme for Jekyll, updated to reflect toned-down line numbers
View solarized-dark.css
/* Solarized Dark
For use with Jekyll and Pygments
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
ebouchut / gist:7040412
Created October 18, 2013 11:45
Get the name of the current git branch
View gist:7040412
git name-rev --name-only $(git rev-parse HEAD)
ebouchut / gist:6699245
Created September 25, 2013 13:01
Javascript regex to test if a language code is RFC5646 compliant [locale] [I18N]
View gist:6699245
private static RegExp buildRegexpLangRfc5646()
String extLang = "([A-Za-z]{3}(-[A-Za-z]{3}){0,2})";
String language =
"(([a-zA-Z]{2,3}(-" + extLang + ")?)|([a-zA-Z]{5,8}))";
String script = "([A-Za-z]{4})";
String region = "([A-Za-z]{2}|\\d{3})";
String variant = "([A-Za-z0-9]{5,8}|(\\d[A-Z-a-z0-9]{3}))";
String singleton = "(\\d|[A-W]|[Y-Z]|[a-w]|[y-z])";
String extension = "(" + singleton + "(-[A-Za-z0-9]{2,8})+)";