Skip to content

Instantly share code, notes, and snippets.

View franky47's full-sized avatar

François Best franky47

View GitHub Profile

Using nuqs for URL Query State Management

nuqs is used for managing URL query state in Next.js applications. Follow these guidelines when working with it:

  1. Import necessary functions from nuqs:

    import { parseAsBoolean, parseAsStringEnum, useQueryState } from "nuqs";
@JaeTLDR
JaeTLDR / __ini__t.py
Created January 20, 2019 07:28
10 hours of fun, flask edition
from flask import Blueprint
bp = Blueprint('botfun', __name__)
from app.botfun import botfun
@kitze
kitze / one-liner-solution.js
Last active November 23, 2018 16:10
Solution
/*
* If the loop bumps into an function, it returns true, and moves on,
* but if it bumps into a number, it waits x milliseconds,
* it stops the _.every loop by returning false, and recursively
* calls the sequence function with the rest of the array.
* Nifty, huh? 😝😝
*/
const sequence = b => b.every((a, i) => !(a.call ? a() : setTimeout(() => sequence(b.slice(++i)), a)));
@mikelehen
mikelehen / generate-pushid.js
Created February 11, 2015 17:34
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@soheilhy
soheilhy / nginxproxy.md
Last active October 23, 2024 08:19
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@nojvek
nojvek / PNGAlphaTrim.py
Created July 19, 2012 06:27
Trim transparency of all PNG files in a folder
import Image
import sys
import glob
# Trim all png images with alpha in a folder
# Usage "python PNGAlphaTrim.py ../someFolder"
try:
folderName = sys.argv[1]
except :
@piksel
piksel / raspi-motd.sh
Created June 30, 2012 12:15
Script for setting a nice raspberry pi logo as MOTD on debian.
#!/bin/bash
logo="$(tput setaf 2)
.~~. .~~.
'. \ ' ' / .'$(tput setaf 1)
.~ .~~~..~. $(tput sgr0) _ _ $(tput setaf 1)
: .~.'~'.~. : $(tput sgr0) ___ ___ ___ ___| |_ ___ ___ ___ _ _ ___|_|$(tput setaf 1)
~ ( ) ( ) ~ $(tput sgr0) | _| .'|_ -| . | . | -_| _| _| | | | . | |$(tput setaf 1)
( : '~'.~.'~' : ) $(tput sgr0) |_| |__,|___| _|___|___|_| |_| |_ | | _|_|$(tput setaf 1)
~ .~ ( ) ~. ~ $(tput sgr0) |_| |___| |_| $(tput setaf 1)
@endolith
endolith / bl_waveforms.py
Last active March 6, 2024 16:20
Band-limited waveform generation in Python/SciPy
# -*- coding: utf-8 -*-
"""
Bandlimited versions of scipy.signal.waveforms.
Intent is mathematical perfection over performance;
these use additive synthesis, so they are slow, but exact.
Less ideal methods using BLIT:
Sawtooth can be made by integrating BLIT minus a DC value to prevent integrator wandering off
Square can be made by integrating bipolar BLIT