Skip to content

Instantly share code, notes, and snippets.

View zipang's full-sized avatar
🏠
Working from home

Christophe Desguez zipang

🏠
Working from home
  • EIDOLON LABS
  • France
View GitHub Profile
@zipang
zipang / use-swipe.ts
Last active May 21, 2025 13:34
useSwipe (React Hook)
import { useEffect, useLayoutEffect, useState, type RefObject } from "react";
type Direction = "top" | "bottom" | "left" | "right";
type Vector = [number, number];
interface UseSwipeOptions {
/**
* Callback for swipe events
*/
onSwipe: (direction: Direction, vector: Vector) => void;
@zipang
zipang / play
Last active May 3, 2025 08:19
Play music files inside a dir (Linux + mpv)
#!/bin/bash
# Name of the playlist file to generate/use
playlist="playlist.m3u"
# Check if the playlist file doesn't exist
if [ ! -f "$playlist" ]; then
# Enable nullglob to handle patterns with no matches
shopt -s nullglob
@julianlam
julianlam / provisioning-unprivileged-lxc-containers-via-login-or-script.md
Last active September 7, 2023 12:45
Provisioning and usage of unprivileged LXC containers via indirect login or script #blog

Provisioning and usage of unprivileged LXC containers via indirect login or script

As I've discovered, managing LXC containers is fairly straightforward, but when building out a system for provisioning out user maintained instances of NodeBB, it was imperative that unprivileged LXC containers were used, so that in the event of shell breakout from NodeBB followed by privilege escalation of the saas user, the root user in the LXC container would only be an unprivileged user on the host machine.

During the course of development, I ran into numerous blockers when it came to managing LXC containers in unexpected circumstances. Namely:

  • Using LXC in a subshell is not directly supported. This usually happens under one of the following two circumstances:
    • After switching users via su or executing lxc-* commands as another user via sudo
    • Executing lxc-* commands via a program, application, or script. In my case, a Node.js application.
@ericelliott
ericelliott / essential-javascript-links.md
Last active June 14, 2025 18:43
Essential JavaScript Links
@PixnBits
PixnBits / md5.js
Last active August 31, 2024 22:27 — forked from jhoff/md5.js
invalid reference fix
/*
* http://www.myersdaily.org/joseph/javascript/md5-text.html
*/
(function (global) {
var md5cycle = function (x, k) {
var a = x[0],
b = x[1],
c = x[2],
d = x[3];
@mckamey
mckamey / bezier.js
Created September 25, 2012 16:35
JavaScript port of Webkit CSS cubic-bezier(p1x.p1y,p2x,p2y) and various approximations
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the