Hi, I am Kiru 👋 an indie hacker, a problem solver and vim-lover. I build projects to make the life of others and mine easier.

This page is intended to collect all my projects and some thoughts.

Recent TILs

Tagged Templates in JavaScript
TIL 25.05.2021

JavaScript supports template strings since ES2015:

const me = "Kiru"
const missing  = 22/7 - Math.PI
console.log(`Print var: ${me} and ${missing}`)
console.log(`This also works: ${22/7} - ${Math.PI} = ${missing}`)

You can pass the tagged templates to functions:

function printTemplates(strings, ...keys) {
  console.log("Strings: ", strings);
  console.log("Keys", keys);
printTemplates`What is possible: ${me}`

Will print:

Strings: ["What is possible: ", "", raw: Array(2)]
Keys ["Kiru"]

Empty multiselect is not set
TIL 28.06.2020

Having the following input:

<label for="cars">Make your choice:</label>
<select name="choice" id="choice" multiple>
  <option value="Yes">Volvo</option>
  <option value="No">Saab</option>
  <option value="Maybe">Saab</option>

If nothing is selected, the name of the property is not sent to the server (e.g. if you expect the full set to be sent to the server)

A hack to fix this is to add a hidden property with the same name.

<input type="hidden" name="myitems" value="" />

Java code comments
TIL 06.12.2019

Nea trick to hide code inside comments by closing enclosing code using unicode:

public class Dafuq {
     * This does not do what you think it does.
     * <p>
     * You think code is documentation? No! Documentation is code!
       static {
    public static void main(String[] args) {

The above code prints “NO”, and taken from here.

The above does only work for child processes (stared by the same shell). The hack works for any processes:

$ tail --pid=$pid -f /dev/null

Learned from to StackOverflow answer.