Skip to content

Instantly share code, notes, and snippets.

View ebouchut's full-sized avatar

Eric Bouchut ebouchut

View GitHub Profile
@ebouchut
ebouchut / start_with_js
Created July 11, 2014 13:56
Test if a string start with another string in Javascript
prefix = "http://";
url = "http://example.com";
url.substring(0, prefix.length) === prefix; // true
@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 / 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)
@ebouchut
ebouchut / gist:6699245
Created September 25, 2013 13:01
Javascript regex to test if a language code is RFC5646 compliant [locale] [I18N]
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})+)";
@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 / gist:4130048
Created November 22, 2012 08:48 — forked from canton7/gist:1053846
git push, tracking, and push.default

git clone path/to/test/repo.git

push.default = matching (the default)

git config push.default matching

git branch -a
   * master
@ebouchut
ebouchut / 0main.md
Created November 21, 2012 12:33 — forked from canton7/0main.md
Local versions of tracked config files

How to have local versions of tracked config files in git

This is a fairly common question, and there isn't a One True Answer.

These are the most common techniques:

If you can modify your application

@ebouchut
ebouchut / GwtChosen-ChromeWidthIssue.png
Created November 15, 2012 16:28
gwt-chosen issue26: ChosenListBox is too narrow on Chrome (optgroups wrap right)
GwtChosen-ChromeWidthIssue.png
@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