Skip to content

Instantly share code, notes, and snippets.

@jiaaro
jiaaro / installing_pyaudio.md
Last active May 2, 2024 10:15
How to install PyAudio into a VirtualEnv on Mac OS X 10.10

Install portaudio using homebrew (or method of your choice)

brew install portaudio

create $HOME/.pydistutils.cfg using the include and lib directories of your portaudio install:

[build_ext]
@jiaaro
jiaaro / main.lua
Created August 14, 2023 21:49
Magic Musicbox v 1.2
--[[
Feature Ideas
- different cycle lengths per instrument
- Setting: "Crank to play", "very slow", "slow", "medium", "fast"
- Setting: set key, scale
- Key: C, C#, etc
- Scale: Major, Minor, Dorian
- change instrument for each track
- 3 drum samples, plus pentatonic scale
- randomize notes
from pydub import AudioSegment
from pydub.utils import db_to_float
# note: see usage example at the bottom of the gist :)
class Mixer(object):
def __init__(self):
self.parts = []
def overlay(self, sound, position=0):
@jiaaro
jiaaro / _INSTRUCTIONS.md
Last active January 22, 2024 17:47
Using Swift libraries in Python

Using Swift libraries in Python

So... this is obviously totally, 100%, like for. real. not. supported. by. Apple. …yet?

But still... I thought it was pretty badass. And, seeing how there's already a Swift buildpack for Heroku you could move some slow code into Swift can call it as a library function. But, you know, not in production or anything. That would be silly, right?

Now, having said that, the actual Python/Swift interop may have bugs. I'll leave that as an exercise to the reader.

How to get Python code calling Swift functions:

@jiaaro
jiaaro / hexcolor.lua
Last active January 13, 2024 09:35
Hex colors to love2d
-- converts CSS-style hex colors to love2d 0 - 1 scaled colors
-- e.g., hexcolor("ccff99") == {0.8, 1.0, 0.6}
-- supports alpha, e.g., hexcolor("ccff9966") == {0.8, 1.0, 0.6, 0.4}
-- supports shorthand, e.g., hexcolor("cf96") == hexcolor("ccff9966")
-- automatically strips common prefixes, e.g., hexcolor("#cf9"), hexcolor("0xcf9")
local function hexcolor(c)
-- strip leading "#" or "0x" if necessary
if c:sub(1, 1) == "#" then
c = c:sub(2)
elseif c:sub(1,2) == "0x" then
@jiaaro
jiaaro / docker-compose.yml
Created October 25, 2023 17:14 — forked from mourjo/docker-compose.yml
Docker compose for a minimal Kibana + Elasticsearch locally
version: '2.2'
services:
es01:
image: docker.elastic.co/elasticsearch/elasticsearch:7.15.1
container_name: es01
environment:
- node.name=es01
- cluster.name=es-docker-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
@jiaaro
jiaaro / check_ticketmaster.py
Created September 28, 2011 21:43
Check for radiohead tickets :(
#!/usr/bin/env python
"""
I really *REALLY* wanted to see Radiohead at Roseland ballroom, but so
did everybody else and the tickets sold out in about 10 minutes. I didn't
get one :(
They haven't played in NYC in 3 years!
Here is a script that checks when tickets become available for an event.
NEVER AGAIN!
@jiaaro
jiaaro / Generate WAV from MIDI.md
Last active April 11, 2023 04:11
Generate a wave file from a MIDI file with Pydub

Simple example of rendering a midi file with Pydub

Basically, this takes a MIDI input file (I just googled and grabbed one of Maroon 5's "Animal" – I know, I know) and generates a WAV file.

NOTE: This is the slowest midi rendering program I have ever seen!

Dependencies:

@jiaaro
jiaaro / demonstrate-bloat.sql
Created April 6, 2023 15:56
Bloat lightning talk
-- Setup
drop table bloattable;
create table bloattable (
a int primary key,
b int not null,
x uuid not null,
y uuid not null
);
@jiaaro
jiaaro / hotkey_helpers.js
Last active February 27, 2023 22:01
Mac Automation – Javascript (JSX) Hotkey helpers
// How to use:
// 1. Open "Script Editor" (requires OS X 10.10 Yosemite)
// 2. Change the language from "AppleScript" to "JavaScript"
// 3. Paste the code below and replace the safari example.
//
// More info:
// https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html
var sys_events = Application("System Events");