No Relation To Blog
Subscribe to the personal musing of Emmanuel Bernard
Flash Gordon et le permis à points
C'est l'histoire de Flash Gordon qui allait tranquillement chez des amis et qui rencontre un radar fixe : clic-clac Kodak, 1 point et 68 €, circuler, y a rien à voir.
Merci les amis pour habiter si loin. Du coup, je me suis renseigné sur les contraventions routières et leurs sanctions en France. Voici le tableau complet mais je voulais vous lister les quelques unes qui m'ont amusé:
B.I. sans I.T.T. par manquement délibéré à une obligation de sécurité - 1500 € et suspension de permis de 3 ans
On ne dit pas ce que B.I. sans I.T.T. veut dire mais c'est 1500€ et suspensions de permis de 3 ans. Pour votre culture personnelle: blessures involontaires sans incapacité temporaire totale.
Transport, détention, usage d'appareil destiné à déceler ou perturber les contrôles - 1500 €, 2 points, 3 ans
On comprend les discussions de Coyote et A Bon Entendeur pour ne pas tomber dans cette catégorie :)
Circulation de véhicule sur une barrière de dégel - 1500 € et 3 ans
En bon parisien, je ne savais pas ce qu'était une barrière de dégel. D'apres Wikipedia, c'est une interdiction de circulation temporaire sur une route donnée pour les gros tonnages en cas de dégel. L'idée est de préserver la chaussée fragilisée par le dégel non homogène.
Conduite en état alcoolique (≥0,10mg/l et <0,4mg/l dans l'air expiré ou ≥0,2g/l et <0,8g/l dans le sang) par conducteur d'un véhicule de transport en commun - 135 €, 6 points, 3 ans
Ça rassure, le niveau d'alcoolémie d'un conducteur d'engin publique est en plus drastique.
Circulation de nuit ou par visibilité insuffisante sans éclairage - 135 €, 4 points, 3 ans
Batman, fait gaffe!
Circulation à gauche sur chaussée à double sens - 135 €, 3 points, 3 ans
Reine Mère ou pas, on roule à droite en France.
Accélération par conducteur sur le point d'être dépassé - 135 €, 2 points, 3 ans
Refus de serrer à droite par conducteur sur le point d'être dépassé - 135 €
Circulation sur bande d'arrêt d'urgence - 35 €, 3 points, 3 ans
Si vous êtes un gros con voire juste un gros boulet, c'est l'amende !
Circulation sur bande centrale séparative d'autoroute - 135 €, 2 points, 3 ans
A mon avis, ce conducteur là cumule avec l'alcoolémie.
Distribution d'imprimé ou d'objet au conducteur ou à l'occupant d'un véhicule circulant sur une voie publique - 135 €
L'histoire de dit pas si la pénalité vaut si on distribue de dehors ou de dedans.
Circulation d'un véhicule non équipé de dispositifs de freinage conformes - 68 €
Si vous roulez sans freins, c'est moins pénalisé que l'excès de vitesse en dessous de 20 km/h.
Non acquittement du péage d'un ouvrage routier - 35 €
Ça devient rentable...
Contraventions commises par les piétons - 4 €
Faites comme moi, roulez en trottinette !
How to control VirtualBox instances from the command line
I got tired of using the graphical interface of VirtualBox to start and stop my VM. After a little googling, I have found a very neat script that lets you control everything from the command line.
The script is detailed on Carlos Acosta's blog and you can download it directly here. One neat thing is that the VM is run headless. One less visual pollution floating around.
Pro tip on git rebase -i
Here is a small tip to improve your efficiency when using dynamic rebasing in Git.
I do my work on topic branches that are forked of master. Before I push my work for review
via a GitHub pull request, I like to clean it up a bit by:
- reordering some commits
- squashing some commits together
- rewriting commit messages
Nothing fancy but it helps improve history readability.
You can of course do that by using git rebase -i and most examples show
how you can go back in time a couple of commits.
git rebase -i HEAD^4 #go back 4 commits ago
There is a nicer and more efficient to do that when you work on topic branches
git rebase -i master
That's it. Pretty stupid but, since you can put any Git object reference, why not use the object where you started to fork off? The rebase will show you all commits between master and your branch.
If you are on a Mac, I highly recommend using GitX or one of his forks. In particular, you can amend the last commit and graphically select what should be staged and unstaged.
Setting global environment variables in IntelliJ IDEA and other test config goodies
When you run a test from IntelliJ idea, you can customize some of
the settings by selecting the list of tests and click Edit Configurations.
From there you can change things like:
- under which module classpath the test is run
- the working directory the test should run from
- virtual machine parameters
- specific environment variables to use
In Hibernate OGM, we use the same test site for all NoSQL solutions. Changing the module classpath is useful in this situation. We also let you refine via an environment variable which hostname runs say MongoDB.
Unfortunately in Mac OS X, graphic applications do not inherit your .bash_profile config. I know, stupid,
but what can you do against the Empire? Workaround!
You can set environment variables from each test but it gets tedious quickly. Alternatively, you can set
an environment variable globally in IntelliJ - what they call parent environment variables.
Go to Preferences and search for Path Variables.
Set your global environment variables here and you are good to go. Note that you can ask a test not to
inherit these global variables if you want to - in the test configuration.
Update:
It turns out I was wrong. Paths Variables is not where global environment variables can be set. If you
know where, please let me know.
Update 2:
To set an environment variable visible by applications in Mac OS X, use
launchctl setenv MYPATH myvar
then restart your IDE (you might need to log out and back in as well).
Thanks @aagahi for the info. This is not great as it's remote from my IDE but at least that works.
BTW, launchctl is supposed to set the data in /etc/lanuchd.conf or $HOME/.launchd.conf. Not on my
system. If anyone knows where the data is put, I'm interested.
Notes to JetBrains:
- your environment variable UI is plain counter productive: either give us a text free area or make tabs and co working
- an option to inherit the
.bash_profileconfiguration would be awesome :)
Dog vs Cat diary
This is not new by any means but I recently saw this joke. As a recent dog owner I must admit I found it too true to not laugh.
Excerpts from a dog's diary
8:00 am - Dog food! My favorite thing!
9:30 am - A car ride! My favorite thing!
9:40 am - A walk in the park! My favorite thing!
10:30 am - Got rubbed and petted! My favorite thing!
12:00 pm - Lunch! My favorite thing!
1:00 pm - Played in the yard! My favorite thing!
3:00 pm - Wagged my tail! My favorite thing!
5:00 pm - Milk bones! My favorite thing!
7:00 pm - Got to play ball! My favorite thing!
8:00 pm - Wow! Watched TV with the people! My favorite thing!
11:00 pm - Sleeping on the bed! My favorite thing!
Excerpts from a Cat's diary
Day 983 of my captivity.
My captors continue to taunt me with bizarre little dangling objects. They dine lavishly on fresh meat, while the other inmates and I are fed hash or some sort of dry nuggets. Although I make my contempt for the rations perfectly clear, I nevertheless must eat something in order to keep up my strength. The only thing that keeps me going is my dream of escape. In an attempt to disgust them, I once again vomit on the carpet.
Today I decapitated a mouse and dropped its headless body at their feet. I had hoped this would strike fear into their hearts, since it clearly demonstrates what I am capable of. However, they merely made condescending comments about what a "good little hunter" I am. Bastards!
There was some sort of assembly of their accomplices tonight. I was placed in solitary confinement for the duration of the event. However, I could hear the noises and smell the food. I overheard that my confinement was due to the power of "allergies". I must learn what this means, and how to use it to my advantage. Today I was almost successful in an attempt to assassinate one of my tormentors by weaving around his feet as he was walking. I must try this again tomorrow but at the top of the stairs.
I am convinced that the other prisoners here are flunkies and snitches. The dog receives special privileges. He is regularly released and seems to be more than willing to return. He is obviously retarded. The bird has got to be an informant. I observe him communicate with the guards regularly. I am certain that he reports my every move. My captors have arranged protective custody for him in an elevated cell, so he is safe, for now...
Bash script to expand file templates
I am working on pushing all my "dotfiles" into a Git repo. Some contains passwords or other private data. It took me longer than expected to write an expander script in bash. So here it is.
Properties are stored as Java properties.
gittoken=123456789012345ab3bc
backup_destination=emmanuel@devnull.com:./backup
The template uses the $placeholder syntax.
# .gitconfig file
[user]
name = Emmanuel Bernard
[github]
user = emmanuelbernard
token = $gittoken
[alias]
co = checkout
undo = reset --hard
cb = checkout -b
br = branch
cp = cherry-pick
[random]
complex-backup-link = $backup_destination
The script is used like
./properties-expander.sh <properties file> <template> <destination>
# For example
./properties-expander.sh ~/secret.properties ~/templates/gitconfig ~/.gitconfig
The script itself is fairly compact though some parts were fairly tricky - thanks stackoverflow :) :
#!/bin/bash
#
# Released under the WTFPL license version 2 http://sam.zoy.org/wtfpl/
# Copyright (c) 2012 Emmanuel Bernard
# -----
# Usage: properties-expander.sh <properties file> <template> <destination>
#
# Properties file:
# PROPERTY1=value1
# PROPERTY2=value2
#help
if [[ $# -ne 3 ]]; then
echo "properties-expander.sh <properties file> <template> <destination>"
exit 0;
fi
echo Expanding $2 to $3 with properties from $1
#read each line including the last one
while IFS=$'\n' read -r line || [[ -n "$line" ]]; do
#get the property name before the first =
property=${line%%=*}
#get the value after the first =
value=${line#*=}
#find a suitable separation character as the value might contain /
candidates='/:.|@#%^&;,!~abcABC' # candidates for separation character
char=$(echo "$candidates" | tr -d "$line")
char=${char:0:1} # choose the first candidate that doesn't appear in the user input
if [ -z "$char" ] # this test checks for exhaustion of the candidate character set
then
echo "Unusable user input: $line"
exit 1
fi
#add regexp rule
SEDEXEC="s${char}\$$property${char}$value${char}g;$SEDEXEC"
done < $1
SEDEXEC="sed -e '$SEDEXEC' $2 > $3"
eval $SEDEXEC
For simplicity, I have put the script in a GitHub gist. Please fork, improve and give me feedback :)
What design philosophy for your projects?
We had a hotted debate recently in the Hibernate Validator team on a given feature. As a result, we started to write down our design philosophy for the library. This is still a work in progress but here it is (original here):
The goal of these projects is to improve developer productivity and ease of use.
When adding a feature, we ask this pool of questions:
- Does it feel like the right way of doing things?
If it is not we tend to wait till the idea matures- Can it be done with an existing construct with similar or less complexity?
Several ways of doing things is counter productive- Is this feature wrong?
Does it encourage bad practice for example?- Is this a popular request?
- Is this feature useful?
That is the reason for asking "What's your use case?"- Is it the most readable approach?
- Is the feature designed consistently with the rest of the library?
None of these questions should slow down innovation but we want high quality libraries. Keeping them both useful and simple is a constant battle against the easier way of adding features ad nauseum. The team believes it is his responsibility to be the guardian of these principles. We are here to make the world a better place, not give food to guideline writers.
What do you think? And what are your design philosophies?
Feedback on Twitter Bootstrap
Everyone and his dog is in love with Twitter Bootstrap, so I figured I would give it a try and build my website with it.
What is Twitter Bootstrap
Twitter Bootstrap is a HTML(5), CSS and JavaScript toolkit offering a grid based scaffolding and a set of UI components to quickly get started. And best of all it does not look bad :)
It is not too difficult to get into it. While it will not really revolutionize people already familiar with Blueprint CSS and CSS in general, it does however bring a set of standardized components that tend to bring good practice to your website:
- nice styling for common constructs like code, tables, inputs etc
- nice set of sprited icons for various elements
- good looking buttons and labels
- nice navigation tools like breadcrumbs, pagination, and of course nav bars
- good largely spaced headline styles
- closable alert and informative messages
- progress bar
- and many more things both static and dynamic
Responsive design
One very interesting feature is built-in support for responsive design. By combining the grid scaffolding and a bit of JavaScript magic, the content of the page adjusts itself to look best for your browser size. That's particularly useful to make a website that looks nice for both big screens and smartphones.
Check it out, change the size of your browser's window and you will see how the website reacts. It's not perfect and cannot match a dedicated website but that's pretty good.
Using it
Understanding how Twitter Bootstrap works and how to use it is relatively easy and quick. The documentation is pretty good and driven by examples. It could use a few extra examples here and there though.
It is not exempt of bugs but overall things are working as expected. I stumbled upon several bugs but most of them were fixed in their latest version (2.0.3). I am unfortunately stuck on version 2.0.1. Does it work on Internet Explorer? Good question, I don't have a IE installed to check it out. If my website looks like crap and you are using Internet Explorer, then the answer is no.
Twitter Bootstrap is built using Less. I unfortunately use SCSS and had to use a port that has not upgraded to 2.0.3 yet.
The curse
Now the big problem with Twitter Bootstrap is that pretty much all websites using it look alike. The most defining element is the nav bar that unfortunately is one of the main signature component of a website. Some themes exist, otherwise you will have to use Less or their Boostrap customizer to get something more unique. I am also not a big fan of their default font style and size which I changed personally.
Verdict
Overall it was a good experience and the UI components at my disposal helped me make a better website. Yes my site look like many Twitter Bootstrap sites out there ; though I took the extra time to customize it more than the average Joe. It is hopefully different enough :)
If you want to explore Twitter Bootstrap with a practical example, check out my website source code.
The perfect storm creates new website and blog
I have been fed up with Wordpress for a while now. Having to upgrade the core plus an average of 4 plugins every time I went to blog was too much. And I am not even mentioning the security risk or the fact that some services flag wordpress installs as malicious websites...
I have been wanting to migrate the blog to Awestruct for a while but frankly got lazy. My core website was already generated with Awestruct and I wanted to give Twitter Bootstrap a try. Twitter Bootstrap is a CSS / javascript / HTML 5 toolkit to get started quickly.
So I started with that and moved my main website to use Twitter Bootstrap. While I was at it, I have refreshed both content and style to get:
- less chatty pages: especially the home page
- better page titles
- add a section on what projects I work on
And boom, I decided to go all in and also update my blog, importing them from Wordpress. I'll give my feedback on both Twitter Bootstrap and moving a blog in a later post. But let me tell you, the actual content migration was the easy part. Realizing after the fact that a couple of 301 redirects were mandatory for Google to be happy was an interesting experience :)
Anyways, let me know what you think of the website and blog refresh.
Customize titles of your terminal window
If you are like me, you use many many tabs in your command line terminal. By the way, iTerm2 is a very nice improvement over the vanilla OS X Terminal app.
To recognize tabs, I like to display the name of the current directory and add the directory it is contained in if more space are left. Open your .bash_profile or .profile file and add the following
function local_dir_and_within {__LAST="${PWD##*/}"
__IN="${PWD%/*}"
__IN="${__IN/#$HOME/~}"
TITLE_TAB="$__LAST in $__IN"
echo -n $TITLE_TAB
}
export PROMPT_COMMAND='echo -ne "\033]0;$(local_dir_and_within)\007"'
Your tab title will now look like hibernate-search in ~/code.