Skip to content

Instantly share code, notes, and snippets.

@mizchi
mizchi / singlefile-frontend.md
Created November 23, 2023 10:27
How to run a minimal front-end stack in Single-File for prototyping.

Original(japanese) https://zenn.dev/mizchi/articles/standalone-html-frontend

Mostly translated by deepl


How to run a minimal front-end stack in Single-File for prototyping.

Note: Do not use in production, tailwind is running in CDN mode and esm.sh builds scripts dynamically, so performance is not good.

@henryivesjones
henryivesjones / postgresql_date_timestamp_interval_cheat_sheet.md
Created February 14, 2023 16:56
PostgreSQL DATE, TIMESTAMP, and INTERVAL cheat sheet

PostgreSQL DATE, TIMESTAMP, and INTERVAL cheat sheet

Working with DATE, TIMESTAMP, and INTERVAL in PostgreSQL can be confusing. In this article I will go over the three date/time related data types, and the two most useful date/time functions: DATE_PART and DATE_TRUNC. Finally, I will provide some real life examples of how these types and functions can be used within queries.

Types

PostgreSQL Date/Time Documentation

DATE

The DATE type contains the year, month, and day of a date. It is not possible to do any type of time related functions on a DATE without first converting it to a TIMESTAMP. Subtracting two DATE values from one another results in an INT representing the # of days between.

TIMESTAMP

The TIMESTAMP type contains a year, month, day, hour, minute, second, and microsecond. This is the type that I most often use.

@Pierstoval
Pierstoval / confirm.Makefile
Last active May 20, 2026 12:09
"confirm" action for your Makefile
# To use the "confirm" target inside another target,
# use the " if $(MAKE) -s confirm ; " syntax.
mycommand:
@if $(MAKE) -s confirm ; then \
execute_your_command_here ; \
fi
.PHONY: mycommand
# The CI environment variable can be set to a non-empty string,
@lyrixx
lyrixx / index.php
Created April 22, 2020 13:20
Very low memory usage iterator
<?php
function m()
{
$memory = round(memory_get_usage() / 1024 / 1024, 2);
$frame = debug_backtrace(0, 1)[0];
$file = basename($frame['file']);
$line = $frame['line'];
printf("%s:%d | %sMb\n", $file, $line, $memory);

high res tiled rendering with canvas-sketch

Copy these files in the gist to a new folder. Generate a package.json:

cd folder-with-code
npm init -y

Then install deps:

@soyuka
soyuka / example-1.js
Last active August 24, 2021 16:38
Promise reflect API by bluebird to handle multiple errors in Promise.all
const Promise = require('bluebird')
const lambdas = require('./lambdas.js')
// Ref: https://stackoverflow.com/questions/25817366/bluebird-promise-all-multiple-promises-completed-aggregating-success-and-rejec
Promise.all(lambdas.map(function(promise) {
// On utilise l'API reflect pour inspecter a la main nos promesses voir http://bluebirdjs.com/docs/api/reflect.html
// grace a ca, la promesse réussira toujours
return promise.reflect();
})).each(function(inspection) {
// Ici la lambda (ou promesse) a réussi
@huntrar
huntrar / full-disk-encryption-arch-uefi.md
Last active October 7, 2026 11:26
Arch Linux Full-Disk Encryption Installation Guide [LUKS2, LVM, Unified Kernel Image, Secure Boot, Evil Maid]

Arch Linux Full-Disk Encryption Installation Guide

This guide provides instructions for an Arch Linux installation featuring full-disk encryption via LVM on LUKS, booting a signed unified kernel image with systemd-boot on UEFI systems.

Following the main installation are further instructions to harden against Evil Maid attacks via UEFI Secure Boot custom key enrollment and a self-signed boot loader and kernel image.

Tested in October 2026 on an HP ZBook Ultra G1a and in a QEMU/OVMF virtual machine: systemd 262, mkinitcpio 42.2, cryptsetup 2.8.8, linux 7.2.9, sbctl 0.18.

Preface

You will find most of this information pulled from the Arch Wiki and other resources linked thereof.

@astoilkov
astoilkov / readme.md
Last active July 8, 2026 09:18
Async Operations with useReducer Hook

Async Operations with useReducer Hook

9 March, 2019

We were discussing with @erusev what we can do with async operation when using useReducer() in our application. Our app is simple and we don't want to use a state management library. All our requirements are satisfied with using one root useReducer(). The problem we are facing and don't know how to solve is async operations.

In a discussion with Dan Abramov he recommends Solution 3 but points out that things are fresh with hooks and there could be better ways of handling the problem.

Problem

@ernierasta
ernierasta / sway-record
Last active August 18, 2022 19:36
Swaywm screen and audio recording
#!/bin/bash
# Sway WM screen + audio recorder
# original author: Aaron D. Fields
# blog post: https://blog.spirotot.com/2017/08/21/a-dirty-hack-to-enable-acceptable-sway-wm-screen-recording/
# currently error 503 :-(
#
# Updated version: ernierasta
# Repo: https://gist.github.com/ernierasta
#
# Changelog:
@mattdesl
mattdesl / sol-lewitt-wall-drawing-273.js
Created October 17, 2018 12:40
Sol LeWitt "Wall Drawing 273" (7th wall) recreated in JavaScript
const canvasSketch = require('canvas-sketch');
const random = require('canvas-sketch-util/random');
const { lerp, lerpArray } = require('canvas-sketch-util/math');
const palettes = require('nice-color-palettes');
const settings = {
dimensions: 'A4',
orientation: 'landscape',
units: 'cm',
pixelsPerInch: 300