nuqs
is used for managing URL query state in Next.js applications. Follow these guidelines when working with it:
-
Import necessary functions from
nuqs
:import { parseAsBoolean, parseAsStringEnum, useQueryState } from "nuqs";
from flask import Blueprint | |
bp = Blueprint('botfun', __name__) | |
from app.botfun import botfun |
/* | |
* 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))); |
/** | |
* 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). | |
*/ |
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
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 : |
#!/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) |
# -*- 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 |