Skip to content

Instantly share code, notes, and snippets.

View ts1's full-sized avatar

Takeshi Sone ts1

View GitHub Profile
@ts1
ts1 / awake.c
Last active August 28, 2020 08:15
Tiny command to detect whether Mac display is awake or asleep
#include <CoreGraphics/CoreGraphics.h>
int main()
{
return CGDisplayIsAsleep(CGMainDisplayID());
}
@ts1
ts1 / update-dns.sh
Created September 4, 2020 06:04
Dynamic DNS update using AWS Lightsail Domain API
#!/bin/bash
set -eo pipefail
DOMAIN=example.com
ENTRY=examplehost
#LINE_TOKEN=xxxxxx
get_ip() {
curl -s 'https://api.ipify.org'
@ts1
ts1 / tmclean.sh
Last active December 29, 2020 11:13
Time Machine cleaner - remove backups not listed in `tmutil listbackups`
#!/bin/bash
set -eo pipefail
DIR=$(tmutil machinedirectory)
backups=$(tmutil listbackups)
ls "$DIR" | while read subdir; do
if echo $subdir | grep -q '[^0-9-]'; then continue; fi
if echo $backups | grep -q $subdir; then continue; fi
dir="$DIR/$subdir"
if [ "$1" = -n ]; then
echo "$dir"
@ts1
ts1 / checksslcert.py
Created December 1, 2020 02:50
Returns the expiration date of the SSL certificate in the number of days remaining, useful for Zabbix external scripts.
#!/usr/bin/env python3
import socket, ssl, sys, time, re
if len(sys.argv) < 2:
print('Usage: %s {HOST|URL} [PORT]' % sys.argv[0])
exit(1)
host = sys.argv[1]
if '://' in host:
@ts1
ts1 / channels.yml
Last active November 16, 2024 10:48
mirakurun channels.yml (地上波は関東J:COM)
- name: 'J:COMテレビ'
type: 'GR'
channel: '13'
- name: 'tvk1'
type: 'GR'
channel: '18'
- name: 'J:COMチャンネル'
type: 'GR'