Skip to content

Instantly share code, notes, and snippets.

@mpaolino
mpaolino / 95-static-soundcard-name.rules
Last active September 26, 2020 01:41
udev rules file to statically name sound cards in alsa and pulseaudio with the same vendor, product and serial id.
# This is a sample ude rules file to staticaly assign names to sound cards (in this case USB) that have the exact
# same product, vendor and serial number. This normally creates card names in pulseaudio that are a combination of this
# attributes plus an auto incrementing numbering, the problem is that the cards will get their names depending on the
# order the cards are plugged in.
# This udev rules fixes that issues by assigning a name to any card that is plugged in the same USB port, I don't know
# any other way.
#
# Name this file something like /etc/udev/rules.d/95-identical-cards-names.rules
# The list of cards should be changed to match your system, the only lines you are supposed to change/remove/add
# are DEVPATHs, look a the comments comments to see where to get the soundcard path.
@mpaolino
mpaolino / 95-identical-cards-names.rules
Last active August 7, 2023 19:36
udev sample rules to make alsa a pulseaudio name USB sound cards with the same product, vendor and serial id
# This is a sample ude rules file to staticaly assign names to sound cards (in this case USB) that have the exact
# same product, vendor and serial number. This normally creates card names in pulseaudio that are a combination of this
# attributes plus an auto incrementing numbering, the problem is that the cards will get their names depending on the
# order the cards are plugged in.
# This udev rules fixes that issues by assigning a name to any card that is plugged in the same USB port, I don't know
# any other way.
#
# Name this file something like /etc/udev/rules.d/95-identical-cards-names.rules
# The list of cards should be changed to match your system, the only lines you are supposed to change/remove/add
# are DEVPATHs, look a the comments comments to see where to get the soundcard path.
@mpaolino
mpaolino / mystream.m3u8
Created May 31, 2016 13:37
m3u8 playlist, over 6 minutes dvr
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-TARGETDURATION:12
#EXT-X-DISCONTINUITY
#EXTINF:8.333,
mystream-0.ts
#EXTINF:8.333,
mystream-1.ts
#EXTINF:8.334,
@mpaolino
mpaolino / gist:9515564
Created March 12, 2014 20:25
geographic polygon calculation
from geographiclib.geodesic import Geodesic
from geographiclib.polygonarea import PolygonArea
# Polygon for roof at http://maps.googleapis.com/maps/api/staticmap?center=33.402285,-111.942715&zoom=20&size=300x300&maptype=satellite&sensor=false&path=color%3ared%7Cweight:1%7Cfillcolor%3awhite%7C33.4022475,-111.9426775%7C33.4022475,-111.9427525%7C33.4023225,-111.9427525%7C33.4023225,-111.9426775%7C33.4022475,-111.9426775
roof_polygon = PolygonArea(Geodesic.WGS84)
roof_polygon.AddPoint(33.4022475, -111.9426775)
roof_polygon.AddPoint(33.4023225, -111.9426775)
roof_polygon.AddPoint(33.4023225, -111.9427525)
roof_polygon.AddPoint(33.4022475, -111.9427525)
roof_polygon.AddPoint(33.4022475, -111.9426775)
import diesel
from diesel import (Client, call, until_eol, until, receive,
fire, send, first, fork, sleep)
import uuid
AMI_PORT = 5038
class AsteriskAMIError(Exception): pass
@mpaolino
mpaolino / slicing_test-numpy_arrays_vs_lists
Created June 20, 2013 16:16
Heavy python list slicing _will_ fuck efficiency, if applicable consider numpy arrays to do the job
mpaolino@guacamole:~$ cat bench_slice.py
import numpy
import timeit
def splitit(arraylist):
step = 10
frame = 160
while len(arraylist) >= frame:
newlist = arraylist[:frame]
arraylist = arraylist[step:]