Thursday, November 15, 2018

Prevent Git for Windows from expanding Linux path to Windows paths

Today I found that Git for Windows (and possible other Linux shells running on Windows as well) would expand strings starting with "/" to the Win32 path.

I discovered this when I tried to do a curl with an argument that starts with a forward slash.

curl -X POST \
   --data 'name=/gerard'

Git for Windows would expand the string /gerard to C:\/Users\/Gerard.Setho\/dev\/bin\/cmder\/vendor\/git-for-windows\/gerard

The details of why Git for Windows does this is here.

The solution is here: We need to turn off a global environment variable.

   --data 'name=/gerard'

Running this same command in Linux would simply ignore MSYS_NO_PATHCONV, so this solution would be portable in both platforms.

Tuesday, August 29, 2017

I created a NodeJS project in GitHub so I wouldn't have to keep writing boiler plate code. It uses

  • Node
  • Express
  • Webpack
  • Angular 1.x
  • Angular UI Router
No unit tests were included in this seed project (yet).

Hope it helps. 

Monday, July 24, 2017

Sparse Numbers

I just completed my Codility test, and one of my solutions ran slowly. Unfortunately, I am unable to find out where the bottleneck might be (its hard to cover all possible test cases within a limited time).

But I think it might be the way I get the next sparse number. My Java implementation is below.

     * @param i assume i to be sparse.
     * @return
    private int getNextSparse(int i) {

        int mask = 0b11;
        int shift = 0;
        while ((i & (mask << shift)) != 0) {

        return (i & (0b11111111_11111111_11111111_11111111 << shift)) | (1 << shift);

I hope to have a YouTube video out to explain all the above soon. (edit: the YouTube vide is here)

Codility Lessons

Recently I've had to do a Codility ( test while applying for a job. It seems to be a pretty popular website (I just been told to do another test today!).

So before I did the test, I tried some of the Tasks in their Lessons, and they were pretty fun. So I'm going to try some of the more interesting looking tasks. I've posted my solutions to GitHub (here) and YouTube (here).

Obviously this is a work in progress, but I'll try to post as many of my solutions as possible.

Monday, May 22, 2017

Spring MVC's ArgumentResolver

Recently a colleague introduced to me the concept of an ArgumentResolver.

In theory, with an ArgumentResolver, one can inject anything into a Spring MVC Controller. They are usually injected as arguments (aka parameters) in the Controller's methods.

So first in the XML configuration we do the below:

            <bean class="com.mycompany.ArgumentResolver"></bean>

Then we implement the class itself:

import org.springframework.core.MethodParameter;
import org.springframework.web.context.request.NativeWebRequest;

public class ArgumentResolver implements HandlerMethodArgumentResolver {
    public boolean supportsParameter(MethodParameter parameter) {
        return parameter.getParameterType().equals(MyClass.class);

    public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {

        // do what you need to return the Argument

Friday, February 10, 2017

An OpenSSL helper

And by that I mean an 'openssl' command line helper. I normally use openssl to create my CSRs and I always have to look up the command line options. Here is a tool that helps me (especially with my very limited use case).

It creates the command command to use with 'openssl' so I don't have to keep checking. Thanks Digicert! If I had my way, I'd use your services, just for this one tool alone.

And after I create the CSR, I usually just check that its done correctly (I don't know why, just obsessive I guess). And I normally have to check that too. So here is the command line.

openssl req -in xxxxxxxxxxxxxxx.csr -noout - text

Tuesday, February 7, 2017

Change the screenshots folder in Mac

This actually works!!