Skip to content

Instantly share code, notes, and snippets.

View finiteautomata's full-sized avatar

Juan Manuel Pérez finiteautomata

View GitHub Profile
clc
pkg load signal
fs = 16000
[audio, fs] = wavread("files/Audio.wav");
%%
%%
%%
@finiteautomata
finiteautomata / random_bins_in_balls.py
Last active May 15, 2017 18:17
Function that returns a list of m integers that sums n
import random
def random_balls_in_bins(balls, bins):
"""
Returns a list of <bins> integers that sum <balls>
We can think this as a problem of bosons:
We have to distribute balls in bins. To model this, we use a shuffle of
In [1]: import lexer
In [3]: lexer = lexer.DibuLexer("[][]1,2,3]")
ERROR: lexer.py:36: Regular expression for rule 't_ID' matches empty string
File "<string>", line unknown
SyntaxError: Can't build lexer
@finiteautomata
finiteautomata / arbol.py
Created June 16, 2016 15:03
Árbol y su constructor
class Arbol(object):
def __init__(self, elemento=None, izquierda=None, derecha=None):
self.r = elemento
if elemento is not None:
if izquierda:
self._izquierda = izquierda
else:
self._izquierda = Arbol()
if derecha:
self._derecha = derecha
@finiteautomata
finiteautomata / ipython_project_directories.md
Last active February 22, 2016 04:56
How to have IPython/Jupyter notebooks in a directory and source in another

How to have a nice separation of code and notebooks in an IPython project

Let's say we would like to have a Python Project in a fashion like this

:~/projects/myproject$ tree -d .
.
├── notebooks
│   ├── notebook1.ipynb
│   └── notebook2.ipynb
└── src
In [3]: for anal in db.year_analysis.find():
...: print anal
...:
{u'idealism': 0, u'_id': ObjectId('5295579f2b5f941bec6b1f50'), u'revolution': 0, u'war': 0.15, u'philosophy': 0}
{u'idealism': 0, u'revolution': 0, u'philosophy': 0, u'year': 1899, u'_id': ObjectId('529559f42b5f941cdd6601cc'), u'war': 0.15}
{u'idealism': 0, u'revolution': 0, u'philosophy': 0, u'year': 1900, u'_id': ObjectId('529559fa2b5f941cdd6601cd'), u'war': 0.35714285714285715}
{u'idealism': 0, u'revolution': 0, u'philosophy': 0, u'year': 1901, u'_id': ObjectId('52955a132b5f941cdd6601ce'), u'war': 0.13333333333333333}
{u'idealism': 0, u'revolution': 0, u'philosophy': 0, u'year': 1902, u'_id': ObjectId('52955a262b5f941cdd6601cf'), u'war': 0.15789473684210525}
{u'idealism': 0, u'revolution': 0, u'philosophy': 0, u'year': 1903, u'_id': ObjectId('52955a532b5f941cdd6601d0'), u'war': 0.15789473684210525}
{u'idealism': 0, u'revolution': 0, u'philosophy': 0, u'year': 1904, u'_id': ObjectId('52955a672b5f941cdd6601d1'), u'war': 0.153846
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec', all_after_pass:false, zeus:true, bundler:false do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" }
# Rails example
watch(%r{^app/(.+)\.rb$}) do |m|
@finiteautomata
finiteautomata / rvm bash prompt
Created November 7, 2013 18:41
The prompt I use for rvm.
# in .bashrc
GREEN="\[\033[1;32m\]"
WHITE="\[\033[0;37m\]"
PS1="$GREEN\$(~/.rvm/bin/rvm-prompt| sed -e 's/..*/(&)/g')$WHITE$PS1"
(qlub)jperez@devartis11:~/qlub$ diff custom.css html/css/custom.css
466c466
< .bx-wrapper {margin-bottom:20px;}
---
> .bx-wrapper {margin-bottom:30px;}
539,564d538
< .ico-fotos {
< width:232px;
< height:230px;
< display:inline-block;