Skip to content

Instantly share code, notes, and snippets.

I need a reminder about how to set up a service in Linux that will run a script at boot time. Put this LSB init script in your /etc/init.d directory and then type

sudo update-rc.d linux_service.sh defaults

to set up the service. This is a wrapper for the script you actually want to run. The "Required-Start" section allows you to choose what Linux services need to be running before your own service is started. (I think my Fluidsynth script probably wants "alsasound".)

Some relevant links about this stuff:

#!/usr/bin/env python
import os
import re
import time
import subprocess
os.system("ps ax | grep fluidsynth | cut -c -6 | xargs kill -9")
devnull = os.open('/dev/null', os.O_WRONLY)
@wware
wware / keypuncher.ino
Created August 18, 2016 20:42
Teensy program to keep your computer awake (and therefore your VPN). Compile with Tools->USB->Keyboard.
int count = 0;
void setup() { }
void loop() {
int i;
Keyboard.print("Hello World ");
Keyboard.print(count);
count = count + 1;
delay(2000);
for (i = 0; i < 20; i++) {
Keyboard.print("\177");
@wware
wware / papertrail.py
Last active August 9, 2016 19:50
You can write decorators for classes! Who knew? This is a decorator to track the history of what happens to instances of the decorated class following the initial call to their constructor.
import types
import inspect
import pprint
from collections import defaultdict
def get_stack(offset=0):
def frame2tuple(frame):
info = inspect.getframeinfo(frame[0])
return (info.filename, info.lineno)
@wware
wware / README.md
Created August 1, 2016 19:17 — forked from leonardofed/README.md
A curated list of AWS resources to prepare for the AWS Certifications


A curated list of AWS resources to prepare for the AWS Certifications

A curated list of awesome AWS resources you need to prepare for the all 5 AWS Certifications. This gist will include: open source repos, blogs & blogposts, ebooks, PDF, whitepapers, video courses, free lecture, slides, sample test and many other resources.


Index:

@wware
wware / teensy_midi.ino
Last active July 1, 2016 20:18
Teensy MIDI controller
const int channel = 1;
const int led = 13;
void setup() {
pinMode(led, OUTPUT);
}
int programs[] = {
1, // acoustic grand piano
9, // celesta
(define (factorial n)
;; tail recursion is fast, and often requires a helper function
(define (helper n product)
(if (< n 2)
product
(helper (- n 1) (* n product))))
(helper n 1))
;; Scheme looping structure
(do
@wware
wware / rdb_fun.py
Last active November 20, 2019 19:57
"""
Provide access to a Bash shell on the remote machine during a RemotePdb session.
"""
import os
import remote_pdb
def rpdb(port=4444):
class RemotePdb(remote_pdb.RemotePdb):
def do_shell(self, arg):