Skip to content

Instantly share code, notes, and snippets.

View janderudder's full-sized avatar

Jan janderudder

  • France
View GitHub Profile
@janderudder
janderudder / wsl-disk-space.md
Last active April 30, 2025 13:55
Reclaim WSL's virtual disk unused space

Reclaim WSL's unused virtual disk space

Compact a WSL distro's virtual disk to reclaim unused storage space.

WSL's virtual disk grows when needed but doesn't shrink by itself. Here is how to reclaim the unused space. This can sometimes free hundreds of GBs for use on Windows.

Trim the WSL partition

@janderudder
janderudder / callable_traits.hpp
Last active September 7, 2023 18:17
Get argument and return type of function or callable object.
#ifndef CALLABLE_TRAITS_HPP_INCLUDED
#define CALLABLE_TRAITS_HPP_INCLUDED
#include <type_traits>
// synopsis
////////////////////////////////////////////////////////////////////////////////
template <typename>
struct callable_traits;
@janderudder
janderudder / keybindings.json
Created October 30, 2022 13:31
VS Code custom keybindings
[
{
"key": "ctrl+shift+alt+p",
"command": "workbench.action.tasks.runTask",
"args": "run premake"
},
{
"key": "ctrl+shift+alt+b",
"command": "workbench.action.tasks.runTask",
"args": "build"
@janderudder
janderudder / dates.sql
Last active September 30, 2022 22:14
SQLite dates storing
CREATE TABLE Dates (
iso TEXT NOT NULL,
julian REAL NOT NULL,
unix INTEGER NOT NULL UNIQUE,
CHECK(iso = date(unix, 'unixepoch', 'start of day')),
CHECK(unix = strftime('%s', date(iso, 'start of day'))),
CHECK(julian = julianday(unix, 'unixepoch'))
);
@janderudder
janderudder / context-menu.html
Last active September 2, 2022 16:15
context menu - custom web context menu example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>context menu (custom)</title>
</head>
<body>
<p>Right-click to display the context menu.</p>
@janderudder
janderudder / cookie-api.js
Created July 25, 2022 16:36
Cookie low level API (js)
@janderudder
janderudder / wsl2-open-ports.ps1
Created March 20, 2022 12:07
Make WSL 2 ports accessible from outside
#
# Run this script as admin
#
# The first two variables should be edited
# according to your situation.
#
$ports=@(80,21,154) # the ports you want to open.
$addr='0.0.0.0'; # target address. 0.0.0.0 is good for most cases.
$wslIP = bash.exe -c "hostname -I"
@janderudder
janderudder / cuttoline.sh
Last active October 9, 2021 10:50
Print all fields line by line. Sorta like cut but knows only one column and outputs all fields.
#!/bin/bash
Base="$(basename -s'.sh' "$0")"
Help()
{
cat <<!
Print all fields line by line.
@janderudder
janderudder / vsc2.sh
Last active October 9, 2021 10:50
vsc new version
#!/bin/bash
#########################################################
## ##
## Create dev project and launch Visual Studio Code ##
## ##
#########################################################
### Please customize here ###
@janderudder
janderudder / mangrep.sh
Last active January 11, 2021 14:50
Man Grep : conveniently search for a command's options descriptions
#!/bin/bash
declare -r Base_name=$(basename -s .sh "$0")
help()
{
cat <<-EOD
Man Grep
Conveniently lookup a keyword in a man page.