Skip to content

Instantly share code, notes, and snippets.

View un1tz3r0's full-sized avatar
😵
Distracted

Victor Condino un1tz3r0

😵
Distracted
View GitHub Profile
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
np.random.randn(i))
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 30 18:55:13 2014
Just intonation classes for music theory experiments in Python
"""
from __future__ import division, print_function
from fractions import gcd as _gcd
from fractions import Fraction
@un1tz3r0
un1tz3r0 / BluetoothSerialThread.java
Created June 16, 2016 02:56
Abstract base class encapsulating communication with a Bluetooth serial profile (SPP) device for Android apps. The abstract methods are called from the thread handling communication through a message handler so they are safe to update the UI from. When the thread is started, it will repeatedly attempt to connect, calling OnConnecting and OnDisco…
package com.example.bluetooth2;
import android.bluetooth.*;
import android.os.*;
import android.util.*;
import java.io.*;
import java.lang.reflect.*;
import java.util.*;
abstract public class BluetoothSerialThread extends Thread
{
@un1tz3r0
un1tz3r0 / CustomSliderView.java
Created July 8, 2016 03:36
A work in progress based on the API Examples LabelView.java custom view, which implements (partially) a custom control similar to SeekBar,
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
This file has been truncated, but you can view the full file.
function GOCR(image){
Module = {
arguments: ['-i', 'in.pnm', '-f', 'UTF8']
}
if(image.getContext) image = image.getContext('2d');
if(image.getImageData) image = image.getImageData(0, 0, image.canvas.width, image.canvas.height);
// if(image.data){
var width = image.width, height = image.height;
var header = "P5\n" + width + " " + height + "\n255\n";
@un1tz3r0
un1tz3r0 / midirepeater.py
Created August 23, 2017 19:16
python midi repeater with dynamic usb via udev
#!/usr/bin/python
import pyudev
import select
import functools
import re
import os
import codecs
fds = {}
devs = {}
@un1tz3r0
un1tz3r0 / private.py
Last active February 9, 2021 09:26
Private/Public dispatch decorators in Python
import inspect
from functools import wraps
def privatemethod(func):
"""decorator for making an instance method private by dispatching on whether the name 'self' in the local namespace of the calling frame is a reference to the same object as the first positional argument (the self argument when invoking an instance method.) the decorated function will have a 'public' member which is a decorator for specifying an alternate implementation to dispatch calls from outside of the instance."""
pubfunc = None
privfunc = func
@wraps(func)
def func_wrapper(*args, **kwargs):
@un1tz3r0
un1tz3r0 / perdevicethreadpool.py
Created August 26, 2018 20:38
This is a sample implementation of a linux udev monitor to watch for devices being added and removed and spawns/stops a reader thread for each active device. The classes are reusable and some are very useful patterns that are common in asynchronous programs. The simple example application at the end demonstrates reading from all connected input …
from contextlib import contextmanager
import pyudev
from select import select
import threading
import select, os, queue, socket
class PollableQueue(queue.Queue):
def __init__(self):
super().__init__()
# Create a pair of connected sockets
@un1tz3r0
un1tz3r0 / cor3-animated-splash-page.markdown
Created September 12, 2018 13:29
cor3 animated splash page