Skip to content

Instantly share code, notes, and snippets.

View saml's full-sized avatar

Sam Lee saml

  • New York, NY
View GitHub Profile
  1. Dining philosopher

They want food so they wait. And end up eating each other.

  1. Given a random number generator that returns a number between [0,1], how would you build a RNG that accounted for weighting?

WAT?

  1. You have two arrays with N integers in them. Merge those arrays using a recursive algorithm so that the integers in the final array are sorted.
@saml
saml / compressor.ny
Created December 6, 2011 04:09
Chris's Dynamic Compressor
;nyquist plug-in
;version 1
;type process
;categories "http://lv2plug.in/ns/lv2core#CompressorPlugin"
;name "Compress &dynamics 1.2.6..."
;action "Compressing..."
;info "Does dynamic (volume) compression with lookahead.\n'Compress ratio' is how much compression to apply. Raise when soft parts\n are too soft, and lower to keep some dynamic range. You can soften the\n soft parts instead of increasing them with values < 0, and invert\n loudness with values > 1 (lower max amp when you do).\n'Hardness' is how agressively to compress. Raise when parts are still\n hard to hear (even with a high compress ratio). Lower when the result\n sounds distorted.\nRaise 'floor' to make quiet parts stay quiet.\nRaise 'noise gate falloff' to make quiet parts (beneath 'floor') disappear.\nLower 'maximum amplitude' if you experience clipping."
;control compress-ratio "Compress ratio" real "" .5 -.5 1.25
;; TO ENABLE ADVANCED SETTINGS: delete one semicolon from the beginning of the next two lines, then add one to following fo
import os
import subprocess
import argparse
import requests
def changed_files(workdir, prevcommit, commit, cmd='git'):
p = subprocess.Popen([cmd, 'diff', '--name-only', prevcommit, commit],
cwd=workdir, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
#!/bin/bash
if (( $# < 1 ))
then
echo "Usage: $0 json url [cred, default=admin:admin]"
echo "example: $0 /tmp/content.tidy.-1.json http://localhost:4502/content/copy"
exit 1
fi
j="$1"
@saml
saml / korean-font-rendering.txt
Created June 27, 2021 12:14
chrome renders awkward
ㅋㅋㅋ 첫번째 장소도 그렇게 어려운곳에 있지는 않았을것 같은데 ㅋㅋ
# -*- coding:utf-8 -*-
import logging
from kombu import Connection, Queue, Exchange
from kombu.mixins import ConsumerMixin
_log = logging.getLogger(__name__)
logging.basicConfig(level='DEBUG', format='%(asctime)s %(levelname)s %(name)s %(lineno)d %(process)d %(processName)s %(message)s')
/*
$ node sequelizeTransactionPoolSize.js
Started promises { count: 5 }
Executing (1cd366d4-a412-4a87-9185-0261f208169b): START TRANSACTION;
Executing (d9eadf8c-7407-4653-9a71-c3f83aee9ca2): START TRANSACTION;
Executing (d1c4e9e1-0fdf-4284-8cfc-9f0f60cc0ff1): START TRANSACTION;
Executing (c3ea6d09-b3e9-44dd-b277-1ac715f9c942): START TRANSACTION;
Executing (89824a8c-766d-490f-9b65-d0baab9b2030): START TRANSACTION;
it just hangs
@saml
saml / penis.svg
Last active February 2, 2021 04:37
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
function runMiddleware(middleware, req, res) {
return new Promise((resolve, reject) => {
function next(value) {
if (value instanceof Error) {
reject(value);
} else {
resolve(value);
}
}
middleware(req, res, next);
#!/bin/bash -xe
progressbar() {
secs="${1:-10}"
while true
do
printf .
sleep "$secs"
done
}