Not today...

comments

Snippet

Git amend history

This post is a simple copy of this answer, go there to see the original. As I am using git extensively in my day to day life/job, I encountered the issue to simply amend a commit which is already two or three commits before the current one. I could use git rebase -i with some stashing to apply the changes at the proper moment. This is most of the time a viable solution, however, it may be complicated because I have too much new code and stashing would be complicated. Read More...

Tagged cli , git

comments

Project

Introducing Y2J (Yaml to Json converter)

This post is only to present a small project and the reasons behind it. Hope it can help other people. Why this project I am massively using jq in my shell scripts to deal with APIs. It is a powerfull tool and really help my day to day work. A few weeks ago I had to do the same kind of operations on a Yaml file, I started looking out there for alternative, and found some tooling which are translating Yaml to Json then push it to jq: here is an example. Read More...

Tagged dev , rust

comments

Snippet

Simple HTTPs server

Sometimes we need to create a simple server saying hello through https. Here is a simple snippet to achieve this in a shell. # first we generate a self signed certificate for domain foo openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes \ -out foo.crt -keyout foo.key -subj "/CN=foo.com" # then we start a server using socat sudo socat "ssl-l:443,cert=foo.crt,key=foo.key,verify=0,fork,reuseaddr" \ SYSTEM:"echo HTTP/1.0 200; echo Content-Type\: text/plain; echo; echo Hello World\! Read More...

Tagged cli , admin

comments

Log, FP and fun in Golang

Golang implementation of a simple logger is subject to some criticism. First, it does not use any extendable pattern, the only interface we can inject to modify the behavior of the logger is a writer interface. Also, the lack of a proper log level control is a subject of discussion in the community here, here, or this blog post. This post is more a reflexion around APIs and tricks in Golang than a production ready package. Read More...

comments

Snippet

Parallel runners with teardown in go

From time to time in go I have to start multiple small services acting in parallel. For example, a ssh server tied to an administration console (one is running on port 80 the other on port 22), or a kafka consumer pushing to a database and a website to serve those informations. You can decouple this in multiple programs, or run them through some kind of a manager and handle everything at the same place. Read More...

Tagged golang , dev

comments

Snippet

Filepath Walk bug?

During the development of a small project I noticed something strange with golang’s function filepath.Walk. If you are going over a directory, and return filepath.SkipDir error on a file entry. The walker will stop. Setup directory First, set up a simple directory to walk mkdir -p foo/baz touch foo/bar touch foo/baz/qux Run the script Now, let’s run this example script, with the previous directory as the entry argument. I will reuse the example from golang documentation website with small changes. Read More...

Tagged golang

comments

Snippet

Cancel copy of huge file in Go

I recently came across this video on Golang programming. I think this was the moment I finally fully understood the power of Go. It is smart, simple and elegant, I love it. Then, a few days later, I was coding on a toy project and I was doing some stuff around the io package to copy huge files. I wanted to achieve copy cancelation during the processing, basically, being able to interrupt. Read More...

Tagged dev , golang

comments

Snippet

direnv

I recently discovered the direnv project. Which helped me a lot for setting up my development environments. I will share a bit of things I use in my daily basis. Python projects This is well documented but here is what I use in python projects to set up a default virtualenv. layout python That’s it! It sets up a virtualenv in your .direnv directory, and load the updated PATH. Golang projects This one is a bit trickier. Read More...

Tagged bash , cli , dev

comments

Snippet

Golang err shadowing

A feature I like in golang is the hability to declare a variable at the assignation time. Something like this: foo := "bar" Here the variable foo will automatically set up as a string with the value “bar”. One more feature is to be able to allocate on same line as doing a comparison. Like this: if foo := "bar"; foo == "baz" { // do something } else { // do something else } This is really handy when it comes to catch errors from an other function: Read More...

Tagged golang , dev

comments

Project

vuecc

I recently discovered Vue.js and I really liked it. You just have to add a script tag and you can start coding using this framework. After a few hours of development, I decided to use SFC (Single File Components) to separate business code from components. And I got a really bad surpise! In order to compile those templates I needed to use a build system (Webpack or Browserify). The tutorial is really good, but… Read More...

Tagged dev , javascript