Skip to content

Instantly share code, notes, and snippets.

Darren Hoo darren

Block or report user

Report or block darren

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View apfs-delete-snapshot.sh
function tmc() {
before=$(df -hl / |awk '{print $3}' |tail -n1)
count=0
for snapshot in $(tmutil listlocalsnapshots /|awk -F. '{print $4}');do
let 'count++'
echo "delete snapshot $snapshot"
tmutil deletelocalsnapshots $snapshot;
done
after=$(df -hl / |awk '{print $3}' |tail -n1)
if [[ $count -ne 0 ]]; then
@darren
darren / switch-darkmode.sh
Created Jan 15, 2019
switch macOS dark mode to prevent iMac image retention
View switch-darkmode.sh
#!/usr/bin/env bash
# 1. what is image retentiion: https://support.apple.com/en-us/HT202580
# 2. Put this file ~/.local/bin/
# 3. then Add this to crontab
# */10 * * * * ~/.local/bin/switch-darkmode.sh
osascript -e '
tell application id "com.apple.systemevents"
tell appearance preferences
@darren
darren / tm.sh
Last active Jan 13, 2019
bash function for clean APFS snapshots
View tm.sh
function tmc() {
before=$(df -hl / |awk '{print $3}' |tail -n1)
count=0
for snapshot in $(tmutil listlocalsnapshots /|awk -F. '{print $4}');do
let 'count++'
echo "delete snapshot $snapshot"
tmutil deletelocalsnapshots $snapshot;
done
after=$(df -hl / |awk '{print $3}' |tail -n1)
if [[ $count -ne 0 ]]; then
@darren
darren / eip.go
Last active Dec 20, 2017
Get external IP address (nat-pmp)
View eip.go
package main
import (
"fmt"
"log"
"github.com/jackpal/gateway"
natpmp "github.com/jackpal/go-nat-pmp"
)
@darren
darren / v2ex_daily.go
Created Apr 27, 2017 — forked from yinheli/v2ex_daily.go
领取 v2ex 每日奖励 golang
View v2ex_daily.go
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"regexp"
"strings"
)
@darren
darren / nlc.sh
Last active Dec 11, 2017
国家图书馆Wifi自动登录脚本
View nlc.sh
#!/usr/bin/env bash
USERNAME= #改成你的读者卡号
PASSWORD= #改成你的读者卡密码
LOGINURL="http://192.168.180.11:8080/nlcwlan/QueryGuest"
PASSWORD=$(echo $PASSWORD|base64)
UA="Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)"
View redis_pubsub_demo.rb
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
You can’t perform that action at this time.