Skip to content

Instantly share code, notes, and snippets.

@tongpu
tongpu / dirvish-statusmail.py
Created January 28, 2014 23:30
A simple script to send an email with important information about a dirvish backup run via email. Also sends an extra email on error. Add it to post-server in your dirvish.conf. Based losely on http://wiki.dirvish.org/FuhHoe
#!/usr/bin/env python
from email.mime.text import MIMEText
import os
import re
import smtplib
mailfrom = 'from@example.com'
mailto = 'to@example.com'
mailerr = 'err@example.com'
@tongpu
tongpu / Init script for Taskserver
Created May 14, 2014 21:04
Taskserver Init and Logrotate configuration for Debian
#! /bin/sh
### BEGIN INIT INFO
# Provides: taskd
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts Taskserver
# Description: Starts Taskserver using start-stop-daemon

Keybase proof

I hereby claim:

  • I am tongpu on github.
  • I am tongpu (https://keybase.io/tongpu) on keybase.
  • I have a public key whose fingerprint is 1E96 34C1 837F F412 EB1A D7AB D807 26D9 F4F0 14C4

To claim this, I am signing this object:

@tongpu
tongpu / uci-guest-wifi.sh
Last active July 14, 2023 12:20
uci script for OpenWRT guest WiFi configuration
#!/bin/sh
uci batch << EOF
add network switch_vlan
set network.@switch_vlan[-1].device='switch0'
set network.@switch_vlan[-1].ports='1t 5t'
set network.@switch_vlan[-1].vlan='2'
set network.guest='interface'
set network.guest.type='bridge'
@tongpu
tongpu / phantomjs-revealjs-slide-capture.js
Last active November 17, 2016 15:56 — forked from soxofaan/phantomjs-revealjs-slide-capture.js
PhantomJS script to capture/render screenshots of the slides of a Reveal.js powered slideshow.
/**
* PhantomJS script to capture/render screenshots of the slides of a Reveal.js powered slideshow.
*/
var page = require('webpage').create();
var args = require('system').args;
// Get url to render from command line.
var url;
if (args.length < 2) {
@tongpu
tongpu / kubectl-bin_PKGBUILD_completion.patch
Last active June 17, 2017 12:34
kubectl-bin bash-completion
--- PKGBUILD 2017-06-17 14:26:50.520424308 +0200
+++ PKGBUILD.completion 2017-06-17 14:29:26.654709540 +0200
@@ -17,4 +17,8 @@
package() {
install -Dm 755 "$srcdir/$_kubectl_file" "$pkgdir/usr/bin/kubectl"
+ install -d 755 "$pkgdir/usr/share/bash-completion/completions"
+ "$pkgdir/usr/bin/kubectl" completion bash > "$pkgdir/usr/share/bash-completion/completions/kubectl"
+ install -d 755 "$pkgdir/usr/share/zsh/site-functions"
+ "$pkgdir/usr/bin/kubectl" completion zsh > "$pkgdir/usr/share/zsh/site-functions/_kubectl"
@tongpu
tongpu / PKGBUILD_sysbench_pgsql.patch
Created October 19, 2017 13:35
Patch for sysbench PKGBUILD to add support for PostgreSQL
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -5,12 +5,12 @@
pkgname=sysbench
pkgver=1.0.9
-pkgrel=2
+pkgrel=3
pkgdesc="Benchmark tool for evaluating OS parameters that are important for a system running a database under intensive load."
url="https://github.com/akopytov/sysbench"
@tongpu
tongpu / aws-env.sh
Created March 5, 2018 16:14
Shell script to export AWS_* environment variables based on the specified profile
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
if [ ${#} = 0 ]; then
profile=default
else
profile=${1}
@tongpu
tongpu / aws-open-role-console.py
Created May 25, 2018 12:43
Open the AWS console with an AWS role secured by `ExternalID`
#!/usr/bin/env python
import click
import configparser
import json
import os
import requests
import webbrowser
from boto.sts import STSConnection
@tongpu
tongpu / PKGBUILD
Last active June 12, 2018 09:09
Updated PKGBUILD for stern-bin to include bash and zsh completion
# Maintainer: Simon Weald <simon[at]simonweald[dot]com>
pkgname=stern-bin
pkgdesc="Multi pod and container log tailing for Kubernetes"
pkgver=1.6.0
pkgrel=2
arch=('x86_64')
url="https://github.com/wercker/stern"
license=('apache')
_stern_file=stern_linux_amd64