Skip to content

Instantly share code, notes, and snippets.

View Drarig29's full-sized avatar
🤠
Exploring the TypeScript AST

Corentin Girard Drarig29

🤠
Exploring the TypeScript AST
View GitHub Profile
@Drarig29
Drarig29 / better-git-checkout.sh
Last active April 20, 2024 11:51
Git checkout with fuzzy search and automatic branch swap between worktrees
function swap_worktree_branch_with() {
# Run the command again to get the error message
error_message=$(git switch $1 2>&1)
culprit_worktree=$(echo $error_message | grep "is already used by worktree at" | cut -d "'" -f4)
if [ -z "$culprit_worktree" ]; then
return
fi
# Save the branch in current worktree, and detach the HEAD so that we can switch to this branch in the culprit worktree
@Drarig29
Drarig29 / response.json
Last active July 28, 2023 09:41
JSON response containing an URL with access token
{
"redirect_uri": "http://localhost/response?access_token=abcde&something_else=bbb"
}
@Drarig29
Drarig29 / noop-proxy.pac
Last active July 13, 2023 12:40
An example PAC file which only returns "DIRECT"
function FindProxyForURL(url, host) {
return "DIRECT";
}
@Drarig29
Drarig29 / config.conf
Created August 19, 2021 11:36
Neofetch custom Manjaro distro name. Result: Manjaro Linux 21.1 "Pahvo"
...
# Distro
DISTRO_NAME=$(lsb_release -sd | sed -e 's/"//g')
DISTRO_VERSION=$(lsb_release -sr | sed -e 's/.0$//g')
DISTRO_CODENAME=$(lsb_release -sc)
# Override distro name
@Drarig29
Drarig29 / enqueuePromise.ts
Last active January 18, 2023 00:31
An IIFE which enqueues a promise in a single promise. Ensures promises are executed in the good order
/**
* Delays a `console.log()` for the given time amount.
*
* @param message A message to log.
* @param duration A delay in seconds.
*/
function delay(message: string, duration: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(() => {
console.log(message);
@Drarig29
Drarig29 / SilentWallpaper.cs
Last active March 4, 2024 12:29
Temporarily set a desktop wallpaper without polluting the Windows settings history
using System;
using System.Runtime.InteropServices;
using Microsoft.Win32;
public enum WallpaperStyle
{
Fill,
Fit,
Stretch,
Tile,
@Drarig29
Drarig29 / reveal-goto.js
Last active April 9, 2020 13:11
reveal.js: goto() slide method
Reveal.goto = slideNumber => {
let indices = Reveal.getIndices(Reveal.getSlides()[slideNumber - 1]);
Reveal.slide(indices.h, indices.v);
};
#!/usr/bin/env python3
# coding: utf-8
class Node:
def __init__(self, value, previous, next_):
self.value = value
self.previous = previous
self.next = next_