Skip to content

Instantly share code, notes, and snippets.

View danilobellini's full-sized avatar

Danilo de Jesus da Silva Bellini danilobellini

  • Sao Paulo, Brazil
View GitHub Profile
@danilobellini
danilobellini / a_hard_night_chord_audiolazy.py
Created October 11, 2013 18:59
A Hard Day's Night first chord with AudioLazy + PyAudio (Based on an example from the Coursera DSP course)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on Thu Oct 10 15:29:33 2013
# @author: Danilo J. S. Bellini
"""
A Hard Day's Night first chord with AudioLazy + PyAudio
"""
from audiolazy import (white_noise, rint, freq_to_lag, zeros, comb, sHz,
str2freq, AudioIO)
@danilobellini
danilobellini / reson.py
Last active March 18, 2017 18:20
Trying to do a time-variant Butterworth filter using SciPy and AudioLazy. Also, a faster time-variant resonator (AudioLazy) for comparison. Both examples includes instantaneous frequency measurements (from Discrete Hilbert Transform).
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on Mon Sep 09 23:06:21 2013
# @author: Danilo J. S. Bellini
"""
AudioLazy time-variant resonator helping instantaneous frequency measurements.
"""
from __future__ import print_function
from audiolazy import (sHz, sinusoid, gauss_noise, line, z, inf, resonator,
@danilobellini
danilobellini / shuffle.coffee
Created August 30, 2013 00:04
Fisher–Yates Shuffle algorithm
#
# Fisher–Yates Shuffle algorithm
#
# Implementation by Danilo J. S. Bellini
randInt = (k) -> # From 0 to k (i.e., sample space has k + 1 values)
Math.round Math.random() * k
shuffle = (data) ->
for idx in [data.length-1..1]
@danilobellini
danilobellini / splinter_example.py
Created July 2, 2013 08:18
Simple Splinter example with both XPath and CSS
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on Tue Jul 2 05:17:13 2013
# @author: Danilo de Jesus da Silva Bellini
# Simple Splinter example with both XPath and CSS
from splinter import Browser
from tempfile import NamedTemporaryFile
data = """
@danilobellini
danilobellini / set_in_test.py
Created June 17, 2013 04:24
Get some statistics from bible
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created on Sun Jun 16 05:19:49 2013
# Danilo de Jesus da Silva Bellini
""" Get some statistics from bible """
from __future__ import print_function, unicode_literals
import os, zipfile, random
try: # Python 2
from urllib2 import urlopen
@danilobellini
danilobellini / prog_languages.py
Created April 18, 2013 04:42
Creates a list with the name of all programming languages there are (based on Wikipedia)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Danilo de Jesus da Silva Bellini
# Created on Thu Apr 18 2013
"""
Prints all programming languages (from Wikipedia)
"""
from bs4 import BeautifulSoup # Needs "pip install beautifulsoup4"
from urllib2 import Request, build_opener
@danilobellini
danilobellini / mastermind.py
Created April 4, 2013 15:32
Mastermind guess description
#!/usr/bin/env py.test
# -*- coding: utf-8 -*-
# Mastermind guess description
# Created on Thu Mar 14 2013
# Danilo de Jesus da Silva Bellini
def mastermind(guess, secret):
"""
@danilobellini
danilobellini / descriptor_example.py
Created March 28, 2013 02:54
Descriptor use case example (based on Luciano Ramalho "Encapsulation with descriptors" video at PyCon 2013)
# -*- coding: utf-8 -*-
"""
Created on Wed Mar 27 23:36:30 2013
Descriptor use case example
@author: Danilo J. S. Bellini
"""
class Quantity(object):
@danilobellini
danilobellini / gist:5022087
Created February 24, 2013 00:45
Gram-Schmidt orthonormalization with itertools.
# -*- coding: utf-8 -*-
# Gram-Schmidt orthonormalization with itertools.
# Copyright (C) 2012 Danilo de Jesus da Silva Bellini
#
# This is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@danilobellini
danilobellini / roleta.py
Created January 16, 2013 11:11
Roleta Romana - Solução em Python para o problema do dojo de PHP que ocorreu no dia 2013-01-15 na iMasters.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 16 01:17:27 2013
Copyright (C) 2012 Danilo de Jesus da Silva Bellini
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.