deno: Get the path of the current script in

In deno obtaining the path of the current script is done via the import.meta.url api:

const scriptPath = new URL(import.meta.url).pathname;

On Windows though this will return a path with unix style path seperators and a leading /:

/D:/Code/deno-path-of-script/main.ts
Read More

Iterating thru an Object in JavaScript

For the longest time if I wanted to iterate thru an object in JavaScript I would write code that looked something like this:

const obj = { a: "foo", b: "bar" };
for (const key of Object.keys(obj)) {
    console.info(key, obj[key]);
}

Since ES2017 there is a better way of doing this using Object.entries() and destructuring:

const obj = { a: "foo", b: "bar" };
for (const [ key, value ] of Object.entries(obj)) {
    console.info(key, value);
}
Read More

Powershell time command

March 10, 2022powershell

I commbined the best parts of this StackOverflow answer and this Super User answer to come up with this solution for a time function in Powershell:

function time {
    $Command = "$args";
    (Measure-Command { Invoke-Expression $Command 2>&1 | Out-Default }).ToString();
}

Example usage:

# time git pull
00:00:01.0804938

Practical WebAssembly

December 17, 2021javascriptwasmconciso

I wrote an article for my company conciso that attempts to show a practical usage of WebAssembly: https://conciso.de/practical-webassembly/.

Use bash.exe to run bash scripts in Windows

September 1, 2021windowswslbash

If you have the Windows Subsystem for Linux (WSL) installed then you can use wsl.exe to start any linux distribution you have installed from the command prompt. What I recently learned about though is that there is a bash.exe as well which can be used to execute a bash script directly.

Read More