Skip to content

Instantly share code, notes, and snippets.

James Robert jiaaro

Block or report user

Report or block jiaaro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:89a7427a1dfabbb6c213
// using jQuery
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
jiaaro /
Last active Aug 29, 2015
formset example code
class MyForm(forms.Form):
is_interesting = forms.BooleanField(required=False)
def __init__(self, *args, **kwargs):
self.object = kwargs['initial']['obj']
super(MyForm, self).__init__(*args, **kwargs)
def save(self):
jiaaro /
Created May 23, 2015
Make a chord progressions
from pydub import AudioSegment
from pydub.generators import Sine, Square, WhiteNoise
from pydub.playback import play
# From
def note_to_freq(note, concert_A=440.0):
from wikipedia:
return (2.0 ** ((note - 69) / 12.0)) * concert_A
# Timings taken on a MacBook Pro (Retina, 15-inch, Mid 2014)
# running OS X 10.10.3
In [1]: import sys
In [2]: print sys.version
2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
In [3]: data = [{str(x): y+z for x in range(10) for y in range(50)} for z in range(500)]
In [4]: import json
jiaaro /
Created Mar 19, 2015
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
jiaaro / Generate WAV from
Last active Jan 31, 2020
Generate a wave file from a MIDI file with Pydub
View Generate WAV from

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!


View 0 What needs to be



  • Analysis | almost all the fields


  • Market | description / latest update
  • Panel | headers

homepage and sidebar features

jiaaro / hotkey_helpers.js
Last active Nov 1, 2019
Mac Automation – Javascript Hotkey helpers
View hotkey_helpers.js
// 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:
var sys_events = Application("System Events");
jiaaro /
Last active Oct 16, 2019
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:

View solution.js
function Event() {
this.listeners = [];
Event.prototype.subscribe = function(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);
You can’t perform that action at this time.