Skip to content

Instantly share code, notes, and snippets.

@Ravarcheon
Ravarcheon / spectralRotation.py
Last active May 19, 2024 20:40
rotates an audio file by 90 degrees in the spectrum while being a reversible process with minimal loss (only floating point errors which are like -150 dB but thats literally silence ahaha~)
import numpy as np
import soundfile as sf
from scipy.fftpack import fft, ifft
def rotateSignal(signal,flip):
if flip:
signal = signal[::-1]
x = np.concatenate((signal, signal[1:][::-1])) # concatenating the array with a reverse of itself makes it such that the fourier transform doesn't layer over a reversed version of itself in the inverse fft
rotSig = ifft(x)

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@valldrac
valldrac / true-black-theme.patch
Last active May 19, 2024 20:37
wip/true-black-theme
commit 154c5879d48d0165b6bf3a37047dc38ee579b0f9 (HEAD -> wip/true-black-theme)
Author: Oscar Mira <valldrac@molly.im>
Commit: Oscar Mira <valldrac@molly.im>
Add dark theme with true black background color
diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt
index 0cdf7dcf91..6ac4eef67f 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationFragment.kt
@lucasferreira
lucasferreira / git.md
Created August 10, 2021 14:26 — forked from leocomelli/git.md
Lista de comandos úteis do GIT

GIT

Estados

  • Modificado (modified);
  • Preparado (staged/index)
  • Consolidado (comitted);

Ajuda

@s1gnate-sync
s1gnate-sync / build-container-vm.sh
Last active May 19, 2024 20:36
Bootstrapping custom virtual machine on chrome os without any dependencies (it reuses existing vm and it's kernel)
#!/usr/bin/env bash
export LC_ALL=C
set -eu
if test "$(id -u)" -ne 0; then
echo "install: must be root"
exit 1
fi
Shader "Unlit/PolyRhythmVisualizer" {
Properties {
_TimeCode ("Input Time", Float) = 0
_OuterRingFreq ("Outer Ring Frequency", Float) = 1
_InnerRingFreq ("Inner Ring Frequency", Float) = 0.922
_RingCount ("Ring Count", Int) = 35
_VibrantFreq ("Vibrant Frequency", Float) = 2
_Vibrant ("Vibrant", Range(0, 1)) = 0.5
_Decay ("Decay", Range(0, 10)) = 2
[Header(Cosine Gradiant)]
import asyncio
import os
import random
from collections import deque
import ssl
from urllib.parse import urlparse
import aiohttp
import polars as pl
import aiofiles
@darkarnium
darkarnium / EnumerateIam.md
Last active May 19, 2024 20:31
A quick and VERY dirty IAM enumeration tool.

Enumerate IAM

The following code will attempt to enumerate operations that a given set of AWS AccessKeys can perform.

Usage

Usage: enumerate-iam.py [OPTIONS]

  IAM Account Enumerator.
@Kaan2626
Kaan2626 / sermo_main.c
Created June 8, 2019 18:54
ESP-IDF Servo Control
/* servo motor control example
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"