Skip to content

Instantly share code, notes, and snippets.

View jeremyvisser's full-sized avatar

Jeremy Visser jeremyvisser

View GitHub Profile
#!/bin/bash
# Install to /usr/local/bin/dkms-sign-module (mode 0744)
# Create /etc/dkms/<module>.conf with contents:
# POST_BUILD=../../../../../../usr/local/bin/dkms-sign-module
set -x
do_sign() {
/lib/modules/$kernelver/build/scripts/sign-file sha256 /etc/kernel/mok/mok.{key,der} "$1"
@jeremyvisser
jeremyvisser / section.go
Created October 15, 2017 22:12
IOS–like "section" command
// Copyright 2017 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
@jeremyvisser
jeremyvisser / vnc@.service
Last active March 13, 2021 12:57
Simple systemd socket-activated VNC server
[Unit]
Description=VNC server
[Service]
Type=simple
User=%i
PAMName=login
Environment=DISPLAY=:9
@jeremyvisser
jeremyvisser / batstat.sh
Created February 25, 2017 01:55
Read battery percentage and charge/discharge state. Useful as a tmux status plugin. Uses shell builtins heavily to be as fast as possible.
#!/bin/sh
set -o nounset
set -o errexit
BAT=/sys/class/power_supply/BAT0
if [[ ! -d $BAT ]]; then
echo 'No battery'
exit 0
@jeremyvisser
jeremyvisser / section.py
Created July 2, 2015 12:52
IOS–like "section" command
#!/usr/bin/env python3
import sys
if len(sys.argv) <= 1:
print('usage: %s <search text>' % sys.argv[0], file=sys.stderr, flush=True)
sys.exit(1)
search = ' '.join(sys.argv[1:])
@jeremyvisser
jeremyvisser / custom.sh
Last active March 12, 2016 11:46
SCLUG Installfest 2015
#!/bin/bash
set -e -x
# required for dpkg to work
export PATH=/usr/bin:/usr/sbin:/bin:/sbin
cat >/etc/apt/sources.list <<EOF
deb http://ap-southeast-2.archive.ubuntu.com/ubuntu/ trusty main restricted multiverse universe
deb http://ap-southeast-2.archive.ubuntu.com/ubuntu/ trusty-updates main restricted multiverse universe
@jeremyvisser
jeremyvisser / bellos.py
Created May 30, 2015 07:26
Alex Bellos' method of winning a guessing game
#!/usr/bin/env python3
""" Test Alex Bellos' method of winning a guessing game.
Take two random numbers, a and b. The objective is to
guess whether a is greater than or less than b.
You might think you have a 50% chance of guessing correctly,
which is true if guessed randomly.
### Keybase proof
I hereby claim:
* I am jeremyvisser on github.
* I am jeremyvisser (https://keybase.io/jeremyvisser) on keybase.
* I have a public key whose fingerprint is CFF4 E176 D294 DAED F603 3FE2 360F 8D38 A532 6F5B
To claim this, I am signing this object:
#!/bin/bash
set -e -x
export LC_ALL=C
sudo apt-get update
sudo apt-get -y install devscripts git dpatch
git clone git://github.com/dotwaffle/rancid-git
@jeremyvisser
jeremyvisser / migrate-4-to-7.py
Last active December 31, 2015 14:29
Naïve migration of Atmail 4 to Atmail 7.1.
#!/usr/bin/env python
""" Atmail 4 to Atmail 7.1 migration
Copyright (C) 2013 Ace Internet Services Pty Ltd
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.