Skip to content

Instantly share code, notes, and snippets.

@jiaaro
jiaaro / install_nodejs
Last active August 8, 2016 12:50
Put the following files in a folder called `bin` (so they'll be `bin/post_compile` and `bin/install_nodejs`)
#!/usr/bin/env bash
set -eo pipefail
NODE_VERSION=$(curl --silent --get https://semver.io/node/stable)
NODE_BASENAME=node-v${NODE_VERSION}-linux-x64
NODE_ARCHIVE="http://nodejs.org/dist/v${NODE_VERSION}/${NODE_BASENAME}.tar.gz"
# make a temp directory
tempdir="$( mktemp -t node_XXXX )"
rm -rf $tempdir
@jiaaro
jiaaro / conv.py
Last active August 29, 2015 14:03
create hstore col
from django.db import connection
def hs_str(s):
s = unicode(s)
return s.replace('"', r'\"')
def dict_to_hstore(d):
hs_data = [u'"{0}" => "{1}"'.format(hs_str(k), hs_str(v)) for (k, v) in data.items()]
hs_data = u",".join(hs_data)
return "u'{0}'::hstore".format(hs_data)
@jiaaro
jiaaro / gist:fda3d04cf76f49f8051e
Created August 6, 2014 21:14
app revenue calculations
Development time: 3 weeks (15 * 8 == 120 hours)
Marketing time: 2 weeks (10 * 8 = 80 hours)
hourly: $200 (must pay well enough to justify risk)
profit target: $40k (200 hrs * $200)
revenue target: $60k (40000 / 0.67, Apple's cut)
--------
@jiaaro
jiaaro / splitstereo.sh
Created August 7, 2014 19:10
Split Stereo Files (ffmpeg)
#!/bin/bash
INFILE="${1}"
LFILE=$(SND="$INFILE" python -c "import os; print '{0}.L{1}'.format(*os.path.splitext(os.environ['SND']))")
RFILE=$(SND="$INFILE" python -c "import os; print '{0}.R{1}'.format(*os.path.splitext(os.environ['SND']))")
echo "Splitting $INFILE into:"
echo " LEFT: $LFILE"
echo " RIGHT: $RFILE"
echo
function Event() {
this.listeners = [];
}
Event.prototype.subscribe = function(fn) {
this.listeners.push(fn);
}
Event.prototype.unsubscribe = function(fn) {
for (var i = 0; i < this.listeners.length; i++) {
if (this.listeners[i] === fn) {
this.listeners.splice(i, 1);
@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 / 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");

MP

dashboard

  • Analysis | almost all the fields

dpm_core

  • Market | description / latest update
  • Panel | headers

homepage and sidebar features

@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 / bpm_detection.py
Created March 19, 2015 16:17
Super simple BPM detection with pydub
from pydub import AudioSegment
from pydub.silence import detect_nonsilent
seg = AudioSegment.from_file("./ghosts_and_stuff.m4a")
# reduce loudness of sounds over 120Hz (focus on bass drum, etc)
seg = seg.low_pass_filter(120.0)
# we'll call a beat: anything above average loudness
beat_loudness = seg.dBFS