Skip to content

Instantly share code, notes, and snippets.

View un1tz3r0's full-sized avatar
😵
Distracted

Victor Condino un1tz3r0

😵
Distracted
View GitHub Profile
@endolith
endolith / peakdet.m
Last active February 14, 2024 21:27
Peak detection in Python [Eli Billauer]
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@pklaus
pklaus / keyring.py
Created February 21, 2010 10:51
Use the Gnome Keyring in a Python program
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# Gnome Keyring in Python
# Shows how to store credentials of type NETWORK_PASSWORD using python.
# Found on <http://www.rittau.org/blog/20070726-01>
# More on the GNOME Keyring: <http://live.gnome.org/GnomeKeyring>
# alternatively have a look at the new universal and actively developed Python Keyring:
# on <http://pypi.python.org/pypi/keyring> and <http://home.python-keyring.org/>
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@rwilcox
rwilcox / installing_python_packages_programatically.py
Created December 26, 2010 17:32
How to use PIP to install Python packages programmatically.py
#!/usr/bin/env python
"""
PIP can stand for PIP Installs packages Programmatically, too!
(and here's how)
Requires:
* Python 2.6 or higher (for print-as-a-function)
* PIP 0.8.2
"""
@sixtenbe
sixtenbe / analytic_wfm.py
Last active May 27, 2024 01:24 — forked from endolith/peakdet.m
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See
@sw
sw / gist:1244446
Created September 27, 2011 06:09
python snippet to enumerate serial ports on Windows
import itertools
import _winreg as winreg
def enumerate_serial_ports():
path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path)
ports = []
for i in itertools.count():
try:
val = winreg.EnumValue(key, i)
@drdaeman
drdaeman / exec_notify.py
Created December 17, 2011 00:03
Listening to Netlink process events on x86_64 Linux systems (kludgy)
#!/usr/bin/env python
import socket
import os
import struct
if getattr(socket, "NETLINK_CONNECTOR", None) is None:
socket.NETLINK_CONNECTOR = 11
CN_IDX_PROC = 1
@Slipyx
Slipyx / Simplex.cpp
Created April 13, 2012 00:06
C++ simplex noise class
/*
===============================================================================
A C++ port of a speed-improved simplex noise algorithm for 2D in Java.
Based on example code by Stefan Gustavson (stegu@itn.liu.se).
Optimisations by Peter Eastman (peastman@drizzle.stanford.edu).
Better rank ordering method by Stefan Gustavson in 2012.
C++ port and minor type and algorithm changes by Josh Koch (jdk1337@gmail.com).
This could be speeded up even further, but it's useful as it is.
@chrisbanes
chrisbanes / PullToRefreshListFragment.java
Created May 15, 2012 14:32
PullToRefreshListFragment
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
public class PullToRefreshListFragment extends ListFragment {
@kamiller
kamiller / draw_rounded.py
Created June 28, 2012 20:07
python rounded rectangle using cairo and arc
def draw_rounded(cr, area, radius):
""" draws rectangles with rounded (circular arc) corners """
from math import pi
a,b,c,d=area
cr.arc(a + radius, c + radius, radius, 2*(pi/2), 3*(pi/2))
cr.arc(b - radius, c + radius, radius, 3*(pi/2), 4*(pi/2))
cr.arc(b - radius, d - radius, radius, 0*(pi/2), 1*(pi/2)) # ;o)
cr.arc(a + radius, d - radius, radius, 1*(pi/2), 2*(pi/2))
cr.close_path()
cr.stroke()