How to avoid git conflicts when working with a team?

A new team member started working on the same project as me the last week.
After checking their first commit, I noticed they mixed refactoring with eclipse auto-formatting. What made this an even worse  transgression was that they have a custom maximum character width defined in their editor.  I am not against aggressively formatting or refactoring code – except when it is related to critical production code.

GIT diff unfortunately cannot handle these kinds of source refactoring changes and lists the whole file as changed. See:

After reading I came across the following gem on stackoverflow (How to avoid git conflicts when working with a team? from User Christopher) which I quote/steal from.

Ask your team three questions:

  1. Do we enforce whitespace conventions?automatically finalize parameters.
  2. Do we generate textual build artifacts? For example, do we minify js, generate css rules from .sass or .scss files, or build xml configurations on the fly? Do we check them in?[…]

These three things cause the vast majority of our collective conflict pain:

Versioning Pain


JQuery Calendar and PHP: Handling Inserts

1) Getting Current Time in Javascript

The ISO 8601 date format can be utilized to convert the date on the browser side to a format that include timestamp information. Quoting from here:

Note that the “T” appears literally in the string, to indicate the beginning of the time element. Times are expressed in UTC (Coordinated Universal Time), with a special UTC designator (“Z”). Used in ATOM RSS feeds.

function fnISO() {
// Only works in Firefox using ECMAScript 5
var now = new Date().toISOString();

Result: 2009-08-06T23:36:31.390Z


Bash script to monitor server HTTP output length and e-mail an alert

Below is an example of a script that uses CURL to monitor the length of various HTTP server outputs and output a response if this is different than 103 characters.
This is my first bash script, so I had some reading/experimenting to do and it is quite rough.

Benchmarking Javascript Engine on Kindle 4 Touch

I had read an article about solving complicated problems with the use of distributed javascript applications. This is very interesting as all devices run javascript including our old 2G and 3G mobile, and ofcourse some e-book readers.

I really would like at some point to work on a project related to this.
In relation to that, I did a benchmark using my Kindle 4 Touch that has an experimental web browser and a 800 mhz cpu.
This was using the SunSpider 1.0.2 JavaScript Benchmark


Optimized Character Escaper for Java

I wanted to write my own character escaper for requests going to Apache Lucent.
After writing my own, I also received feedback from programmers-stackexchange which resulted in the fastest implementation, also posted here. (Thanks to MrSmit42)

Below is my application that tests 6 different slightly different implementations over 30,000,000 executions each and outputs the time in MS.

The results in MS (on my computer) were the following:

Method 1 (Boolean Array)->    7574
Method 0 (Switch Stmt)->    9778
Method 4 (Switch Stmt Ugly – BreakPoints after evert case)->    12451
Method 6 (HashSet)->    17273
Method 5 (EnumMap)->    39516
Method 3 (Pattern/Regex)->    98229

This proves that for production systems that have many requests, jumping directly on the RegEx bandwagon for even trivial problems is not always the solution.
Even a 0,5 MS reduction per request leads to 50MS saved over 100 requests (per second) and 500MS over 1000 requests.

[polldaddy poll=7418939]


Greesemonkey Script for filtering Stackoverflow Bounty Page

I’m a big fan of stackoverflow and many times surf the featured page that has many questions that have an additional bounty attached.
One of the things though that I want to do is quickly find the questions with zero answers that have not received attention due to one reason or another (e.g. very difficult).

For the specific URL: , Below a greesemonkey script just for that!


Why Java passes objects as references passed by value

I came across a question recently on stackoverflow that was very enlightening and proves how objects are actually passed in java. It was quite an interesting discovery!

I am quoting from here


Java is always pass-by-value. The difficult thing can be to understand that Java passes objects as references passed by value.

It goes like this:

public void foo(Dog d) {"Max"); // true
  d = new Dog("Fifi");"Fifi"); // true

Dog aDog = new Dog("Max");
foo(aDog);"Max"); // true

In this example will still be “Max”. “d” is not overwritten in the function as the object reference is passed by value.


public void foo(Dog d) {"Max"); // true

Dog aDog = new Dog("Max");
foo(aDog);"Fifi"); // true

SO:Removing duplicate rows from data pulled from db in java

I’ve become an active member of stack overflow, both answering and making questions.
It’s amazing, there’s a whole community there that I hadn’t noticed before.
As I have not had time to post new items, I will be borrowing my answers to stackoverflow questions and re posting them here.

User Question:

So here’s my question. I have a giant text file of data and I need to input all of this data into a mySQL database fast through obviously using a java program. My only problem is that, the data is identified by a certain ID. Some of these ID’s have duplicates and contain all the same info as eachother. I would like to remove all of these for sorting purposes and clarity sake.

What would be the best way to go about this? If anyone could help I’d appreciate it




While reading the data have a hashmap or hashset. check if the id exists in the hasmap/hashset and if so continue. otherwise enter in set/map and insert.

An aside: The difference between hashmap and hashset is hashset only takes values while hashmap takes key values. However, Hashset itself uses a hashmap within memory and just inserts a dummy object for values. See: Differences between HashMap and Hashtable?


How to search all columns of all tables in a microsoft sql database for a keyword (including any data type)


I’ve been working on a very large unknown database (over 45 tables) where the reverse engineered schema diagram was quite chaotic. Having the task to find several needles in the haystack I searched the internet and found the very useful script at:  (pasted below).

However, one limitation I noticed was that the script only searched (‘char’, ‘varchar’, ‘nchar’, ‘nvarchar’).


Encrypt in VB.NET and Decrypt in PHP 4 Using Phpseclib0.3.0

Originally I had found code from: Encrypt in VB.NET and Decrypt in PHP and Vice Versa .

Everything worked well, until I realized that the specific webserver I was writing code for ran PHP 4…No mcrypt_decrypt.

Hence I discovered PHPSecLib has the Rijndael algorithm implemented as PHP code.
Following please find code to check if mcrypt exists and react differently (where $line is the encrypted text):

$dec = decryptRJ256($ky, $iv, $line);
$dec = decryptRJ256_PHPSECLIB($ky, $iv, $line);