Skip to content

Instantly share code, notes, and snippets.

View varunpant's full-sized avatar

Varun varunpant

View GitHub Profile
#!/usr/bin/env python
import multiprocessing
import random
import time
class Logger:
def __init__(self, num_lines, last_output_per_process, terminal_lock):
self.num_lines = num_lines
@todbot
todbot / synthio_midi_synth.py
Last active June 23, 2024 08:27
pretty usable MIDI-controlled synth using synthio in CircuitPython
# synthio_midi_synth.py - pretty usable MIDI-controlled synth using synthio in CircuitPython
# 11 May 2023 - @todbot / Tod Kurt
# Uses cheapie PCM5102 DAC on QTPY RP2040
# Video demo: https://www.youtube.com/watch?v=N-PbbWWDE6k
# Features:
# - midi velocity controls attack rate (gentle press = slow, hard press = fast)
# - notes have small random detune on all oscillators to reduce phase stacking
# - adjustable number of detuned oscillators per note 1-5 (midi controller 83)
# - five selectable waveforms: saw, squ, sin, noisy sin, noise (midi controller 82)
# - vibrato depth on mod wheel (midi controller 1)
@campoy
campoy / letitfail.go
Last active January 6, 2024 07:26
This example shows how to have a set of goroutines running concurrently and processing requests. Panics from goroutines are recovered and the worker is restarted. You can download it and run it directly using `go run letitfail.go`
package main
import (
"bufio"
"fmt"
"os"
"time"
)
const numWorkers = 3
@whitingx
whitingx / meta-tags.md
Created October 5, 2012 16:41 — forked from kevinSuttle/meta-tags.md
Complete List of HTML Meta Tags

Copied from http://code.lancepollard.com/complete-list-of-html-meta-tags/

Basic HTML Meta Tags

<meta charset='UTF-8'>
<meta name='keywords' content='your, tags'>
<meta name='description' content='150 words'>
<meta name='subject' content='your website's subject'>
<meta name='copyright' content='company name'>
@jgeewax
jgeewax / handlers.py
Created June 16, 2012 19:57
webapp2_extras auth example (copy/paste)
# -*- coding: utf-8 -*-
"""
A real simple app for using webapp2 with auth and session.
It just covers the basics. Creating a user, login, logout and a decorator for protecting certain handlers.
PRE-REQUIREMENTS:
Set at secret_key in webapp2 config:
@perrygeo
perrygeo / nearest_features.py
Created April 25, 2012 21:51
Find the nearest point features in a shapefile to a given coordinate
import numpy as np
from scipy.spatial import KDTree
from fiona import collection
def nearest_features(datasource, x, y, n=1):
"""
datasource: The ogr datasource path
x, y: coordinates to query for nearest
n: number of features (default = 1 or the single nearest feature)
@rnorth
rnorth / gist:2031652
Created March 13, 2012 21:14
Cookie-based authentication with nginx
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}