Posts

Eclipse behind a corporate proxy

Image
If you're working in a big company, chances are that you are behind a corporate proxy and it can become very annoying because they tend to limit developement tools. As a Java developer, I use Eclipse as my default IDE. The simplest way Go to Preferences > General > Network Connections, then in Active Provider choose Manual. Then enter your proxy address, your port and your username and password. The hardest way If you're on Windows and you don't have an explicit username/password couple, then it must be an NTLM proxy, in this case choose Direct in Active Provider then open your eclipse.ini file ( configuration file that you can find in your eclipse directory ). And add this line : -vmargs Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclient4 Restart Eclipse and evertyhing should be working.

npm behind a proxy

If you're sitting behind a corporate proxy, chances are that you're facing some difficulties configuring npm. The simplest commands to configure npm are : npm config set proxy http://username:password@host:port npm config set https-proxy http://username:password@host:port In most cases this should work, if not then you should feel special 😁. Case 1 : a special password If your password contains special characters, then you must URL encode it, you can find a decent online encoder here .

The "2-Minute Rule"

I don't know if it applies to you too, but I think that, we, developers are the most procrastinators in the world. We like to postpone stuff, we don't like to code unit tests, we don't like to comment our code, well you got the idea. What if I tell you that there is a simple rule that will help you crush procrastination, it's so simple that couldn't be easier to use : The "2-Minute Rule" . The "2-Minute Rule" helps you to overcome laziness by making it so easy to start taking action. Here you go : If a task takes less than two minutes to complete, then follow the rule and do it right now. I'm feeling lazy If you're feeling lazy about doing something, here is the trick to overcome the laziness. Ask yourself if this task does take less than two minutes, if so do it immediately without hesitation. Doing these small tasks will let you build momentum and gain confidence. You should give a try If answering an email will take less ...

A detective developper

The title of this article consists of two different jobs, a detective and a developer, but believe me they have a lot in common. It's not about solving murders or about catching thieves, it's about making your code confess. In this article, I'll try to lay out some of the skills you have to master as a developer so you can find the cause of the toughest bugs. Approach Looking for the suspect without a plan is like looking for a needle in a haystack. The first thing is to have a way to proceed in an organized fashion. Reproduce the bug If you can reproduce the bug go to the next section, if not then you have to gather as much information as possible about the problem. This is important because how is it possible to validate your solution if you cannot reproduce the bug ? Correct the bug Once the bug is reproduced, it's time to correct. But sometimes correcting the problem can be challenging. It might need the heavy artillery, here is some tips to pinpoint t...

The magic of enums

In most cases when I make code reviews, I notice that many developpers prefer flat constants like these : // Constantes : Voitures public static final int VOITURE_ELECTRIQUE = 0; public static final int VOITURE_DIESEL = 1; public static final int VOITURE_ESSENCE = 2; // Constantes : Etats public static final int ETAT_MARCHE = 0; public static final int ETAT_ARRET = 1; This technique was à la mode in languages like C, but nowadays it has many flaws : There is no validation, I can set any value, When debugging, we only see a values that do not have any sense, If these values are hard-coded, the code will be a maintainance nightmare, etc. The solution to this anti-pattern is a type that has been present in Java since its 1.5 version : enumerations. public enum Voiure { ELECTRIQUE, DIESEL, ESSENCE } public enum Etat { MARCHE, ARRET } Using enumerations has many advantages, to name a few : They are explicit, the name of the constant is its value, They are easy to test (usi...

What type to choose ?

Usually, when developping we don't ask ourselve a lot of questions about the type of a variable, a class's field or anything that has a type. Sometimes, we use a jack-of-all-trades type like String. But, is it the right choice. Choosing a type can be trivial. A bad choice though, can lead to polluted code and maintenance problems and sometimes to performance concerns. Let's take a look at this piece of code : // Minimum date private String dateMin ; // … // Person's age private String age ; // … private int valid; The first field is stringified date, if we want to display this date we have to convert it to the right format thus needing a pattern, an information that we don't have. We'll have serious problems if we have a multi-language app where the date must be displayed correctly depending on the language. This field should be a date. The second field represents a person's age, this data needs more memory than an integer, and comparing two a...