Skip to content

Instantly share code, notes, and snippets.

@DennisTT
DennisTT / prep.sh
Last active November 16, 2022 09:52
Script to change hostname and write network configuration for a Ubuntu 22.04 VM guest on an OVH dedicated server
#!/bin/bash
# Setup OVH VM guest networking on Ubuntu 22.04
# Change hostname
read -p "Enter new fully-qualified domain name: " fqdn
hostname=${fqdn%%.*}
echo "Changing FQDN to $fqdn, hostname to $hostname"
sudo hostnamectl set-hostname $hostname
sudo sed -i "s/\(^127\.0\.1\.1.*$\)/127.0.1.1\t$fqdn $hostname/g" /etc/hosts
@DennisTT
DennisTT / surveillance_home_ptz.py
Last active March 22, 2019 01:43
Synology Surveillance Station - Move Camera to PTZ Preset Depending on Home Mode
#!/usr/bin/env python3
"""
Scroll to the bottom and change your IP address (if running the script from another host), Surveillance Station account and password,
the camera name and presets. It shouldn't be too hard to add some other cameras and presets if you know a bit of programming.
Add a task in DSM Task Scheduler to execute this file every minute.
In case you want to extend this script further to do other stuff, the complete documentation for the Surveillance Station Web API can be found at:
https://global.download.synology.com/download/Document/DeveloperGuide/Surveillance_Station_Web_API_v2.8.pdf
@DennisTT
DennisTT / mac_memory.py
Created November 9, 2017 23:10
Collectd - Mac Memory Plugin
#!/usr/bin/env python
# Send more accurate memory readings from Mac OS X than the default plugin
# Calculations from: http://badrit.com/blog/2014/5/1/how-to-calc-memory-usage-in-mavericks-programmatically
import collectd
import subprocess
import re
PAGE_SIZE = 4096 # From the top of `vm_stat`
@DennisTT
DennisTT / speedtest-cli-pull.sh
Created March 14, 2016 11:31
Speed test client, Munin pulling data
git clone git://github.com/sivel/speedtest-cli.git speedtest-cli
@DennisTT
DennisTT / speedtest-cli.sh
Last active March 14, 2016 11:06 — forked from deveth0/speedtest-cli.sh
Speed test client pushing data to munin server
git clone git://github.com/sivel/speedtest-cli.git speedtest-cli
@DennisTT
DennisTT / Preferences.sublime-settings
Last active March 23, 2016 19:19
Sublime Text 3 User Preferences
{
"font_size": 14,
"rulers":
[
80
],
"scroll_past_end": true,
"indent_to_bracket": true,
"tab_size": 4,
@DennisTT
DennisTT / Default (OSX).sublime-keymap
Last active January 2, 2016 15:59
Sublime Text 3 Keymap that maps some of the keys I am used to from Xcode
[
{ "keys": ["control+super+left"], "command": "jump_back" },
{ "keys": ["control+super+right"], "command": "jump_forward" },
{ "keys": ["shift+super+o"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["control+shift+l"], "command": "expand_selection", "args": {"to": "line"} },
{ "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
]
@DennisTT
DennisTT / stagingdiff
Created February 4, 2013 23:55
Opens up DiffMerge comparing a local version of the file (base) with a modified version on a remote machine. Assumes that the directory structure is the same after "cache directory" configuration value.
#!/bin/bash
# Opens up DiffMerge comparing a local version of the file (base) with a modified version
# on a remote machine. Assumes that the directory structure is the same after "cache
# directory" configuration value.
# Configuration values
LOCALCACHEDIR="/var/repo/cache/"
REMOTECACHEDIR="/home/remoteuser/repo/cache/"
REMOTESERVERNAME="staging"
@DennisTT
DennisTT / .gitconfig
Created August 28, 2012 23:37
My .gitconfig
[user]
name = Dennis Tsang
email = email@example.com
[color]
ui = true
[alias]
st = status
ci = commit
br = branch