Skip to content

Instantly share code, notes, and snippets.

View ebouchut's full-sized avatar

Eric Bouchut ebouchut

View GitHub Profile
@ebouchut
ebouchut / disable_postgres_autostart_on_macos
Created April 16, 2014 08:42
Disable Postgres (installed with Homebrew) autostart on MacOS
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
@ebouchut
ebouchut / git_ref_to_sha1
Created January 15, 2013 15:44
git SHA1 to reference name conversion (back and forth)
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
ebouchut / LighttpdReverseProxyURLRewriting
Last active January 27, 2021 20:35
Lighttpd reverse-proxy to that matches an URL _and_ does URL rewriting #web #server #lighttpd
#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:
# http://redmine.lighttpd.net/issues/164#note-9
@ebouchut
ebouchut / WhereDoesMavenDependencyComesFrom
Last active November 25, 2020 10:09
How to check where a maven dependency comes from #maven #find #dependency
#
# To check from where a maven dependency comes from
#
mvn dependency:tree -Dincludes=groupId:artifactId
@ebouchut
ebouchut / formatDateAsUTC.java
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();
calendar.setTime(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
return sdf.format(date);
}
@ebouchut
ebouchut / set_SQL_sequence.sql
Last active July 29, 2019 14:23
Set SQL sequence
-- 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
ebouchut / multi_cherry_pick
Created August 16, 2012 12:21
Cherry pick multiple commits
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
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
/* Solarized Dark
For use with Jekyll and Pygments
http://ethanschoonover.com/solarized
SOLARIZED HEX ROLE
--------- -------- ------------------------------------------
base03 #002b36 background
base01 #586e75 comments / secondary content
@ebouchut
ebouchut / gist:7040412
Created October 18, 2013 11:45
Get the name of the current git branch
git name-rev --name-only $(git rev-parse HEAD)