Skip to content

Instantly share code, notes, and snippets.

View rxw1's full-sized avatar
☠️

rxw1

☠️
  • Germany
View GitHub Profile
#!/usr/bin/python
# credit https://gitlab.com/lyze237/dotfiles-public/blob/master/dotfiles/config/awesome/scripts/defaultSink.py
#
# TODO: if jack is present, ignore Focusrite sink
import os
import re
from subprocess import check_output, call
@reagent
reagent / 00_README.md
Last active January 31, 2025 08:46
Custom HTTP Routing in Go

Custom HTTP Routing in Go

Basic Routing

Responding to requests via simple route matching is built in to Go's net/http standard library package. Just register the path prefixes and callbacks you want invoked and then call the ListenAndServe to have the default request handler invoked on each request. For example:

package main

import (
@spjutbjorn
spjutbjorn / fan.ino
Created April 14, 2017 10:54
arduino 25khz pwm drive
word VentPin = 3;
void setup() {
pinMode(VentPin, OUTPUT);
pwm25kHzBegin();
}
void loop() {
pwmDuty(19); // 25% (range = 0-79 = 1.25-100%)
delay(5000);
@ssokolow
ssokolow / x11_watch_active_window.py
Last active February 22, 2025 20:46
python-xlib example which reacts to changing the active window
#!/usr/bin/env python
"""python-xlib example which reacts to changing the active window/title.
Requires:
- Python
- python-xlib
Tested with Python 2.x because my Kubuntu 14.04 doesn't come with python-xlib
for Python 3.x.

Best practices for building Vim plugins

2016-11-05 VimConf 2016

@hyamamoto
hyamamoto / string.hashcode.js
Created September 30, 2016 07:19
JavaScript Implementation of String.hashCode() .
/**
* Returns a hash code for a string.
* (Compatible to Java's String.hashCode())
*
* The hash code for a string object is computed as
* s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1]
* using number arithmetic, where s[i] is the i th character
* of the given string, n is the length of the string,
* and ^ indicates exponentiation.
* (The hash value of the empty string is zero.)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
int main(int argc, char *argv[])
{
unsigned long value;
char *terminatedAt;
@jkullick
jkullick / secure-mailserver-postfix-dovecot-letsencrypt-debian-jessie.md
Last active March 8, 2024 18:14
Secure Mailserver with Postfix, Dovecot and Let's Encrypt on Debian Jessie

Prerequirements

Config Options

export FQDN="mail.example.org"
export DOMAIN="example.org"
export MAILBOX="user"
export DEBIAN_FRONTEND="noninteractive"
export A_RECORD=$(curl -sSL https://icanhazip.com)
@lukechilds
lukechilds / get_latest_release.sh
Created August 9, 2016 19:43
Shell - Get latest release from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
# Usage
# $ get_latest_release "creationix/nvm"
# v0.31.4
@level323
level323 / altnetworking.sh
Created August 3, 2016 21:14
Run a command inside a customised networking environment (using cgroups)
#!/bin/bash
# === INFO ===
# altnetworking.sh
# Description: Run the specified application in a custom networking environment.
# Uses cgroups to run process(es) in a network environment of your own choosing (within limits!)
VERSION="0.1.0"
# Author: John Clark
# Requirements: Debian 8 Jessie (plus iptables 1.6 from unstable)
#