Skip to content

Instantly share code, notes, and snippets.

# To record both mic and other audio input sources we need to add a named output sink. See:
# http://www.linuxquestions.org/questions/linux-software-2/alsa-and-pulseaudio-recording-multiple-input-devices-877614/
# http://www.youtube.com/watch?v=oJADNOY615Y&feature=player_embedded
# Add this to your /etc/pulse/default.pa file
load-module module-null-sink sink_name=stream
load-module module-loopback latency_msec=5 sink=stream
load-module module-loopback latency_msec=5 sink=stream
@m13253
m13253 / dumpargv.py
Created December 30, 2014 14:03
A script which dumps the command line passed to it
#!/usr/bin/env python
'''Dump the command line passed to it'''
import sys
def quote_argv(argv):
for i in argv:
apos = ' ' in i or '\\' in i
@m13253
m13253 / usbreset.c
Created November 2, 2014 16:26
Send a USB port reset to a USB device -- http://askubuntu.com/a/661/299378
/* usbreset -- send a USB port reset to a USB device */
/* http://askubuntu.com/a/661/299378 */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/usbdevice_fs.h>
@m13253
m13253 / kbgrid_horz.svg
Last active August 29, 2015 14:06
Image representing MIDI keyboard
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Geordi memory dumper
geordi: {size_t s=0x400000;printf("0x%08zx: ",s);for(size_t p=s;p<s+64;p++){unsigned char c=*(const unsigned char *)p;printf((c>31&&c<127)?"%c":"\\x%02x",c);}}
@m13253
m13253 / gensslcert.sh
Last active August 29, 2015 14:04
Generate a self-signed SSL certificate for web server
#!/bin/bash
set -e
outpemfile="${1:-cert.pem}"
tmpprefix="/tmp/gensslcert-$$"
openssl genrsa -des3 -out "$tmpprefix.key" 2048
openssl req -new -key "$tmpprefix.key" -out "$tmpprefix.csr"
openssl rsa -in "$tmpprefix.key" -out "$outpemfile"
rm -f "$tmpprefix.key"
openssl x509 -req -days 365 -in "$tmpprefix.csr" -signkey "$outpemfile" -out "$tmpprefix.crt"
/* [wxMaxima batch file version 1] [ DO NOT EDIT BY HAND! ]*/
/* [ Created with wxMaxima version 13.04.2 ] */
/* [wxMaxima: input start ] */
FlashRot:matrix(
[ cos(rotY)*cos(rotZ), cos(rotY)*sin(rotZ), sin(rotY), 0],
[-sin(rotZ), cos(rotZ), 0, 0],
[-sin(rotY)*cos(rotZ), -sin(rotY)*sin(rotZ), cos(rotY), 0 ],
[trX, trY, 0, 1]);
/* [wxMaxima: input end ] */
@m13253
m13253 / retry.sh
Created May 24, 2014 15:53
A shell script to keep trying a command until it succeeds
#!/bin/bash
_RETRY_COUNT=0
while true
do
("$@") && break
let _RETRY_COUNT=${_RETRY_COUNT}+1
echo -e "\e[1;31mRetry ${_RETRY_COUNT}...\e[0m"
sleep 0.5; echo -ne '\a'; sleep 0.5; echo -ne '\a'; sleep 0.5; echo -ne '\a'; sleep 0.5
done
@m13253
m13253 / dnsmasq.conf
Created May 12, 2014 14:46
My dnsmasq configuration
# Configuration file for dnsmasq.
#
# Format is one option per line, legal options are the same
# as the long options legal on the command line. See
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
# Listen on this specific port instead of the standard DNS port
# (53). Setting this to zero completely disables DNS function,
# leaving only DHCP and/or TFTP.
#port=5353
@m13253
m13253 / imgopt.sh
Last active March 7, 2016 07:12
Optimize large-size images for web by interlacing
#!/bin/bash
# This program is released under MIT license.
# This program comes with absolutely no warranty and may cause damages, use it at your risk.
# The author of this program is StarBrilliant <echo bTEzMjUzQGhvdG1haWwuY29tCg== | base64 -d>
if [ "$#" -eq 0 ]
then
echo "Optimize large-size images for web by interlacing"
echo "Usage: $0 1.png 2.jpg ..."
echo "optipng and libjpeg are required."