Skip to content

Instantly share code, notes, and snippets.

清理时间机器备份遗留的快照命令行工具

把这两个函数定义放入~/.profile

function tmc() {
	for d in $(mount  |grep Time|awk '{print $3}'); do
		diskutil umount "$d HD";
	done
	
@darren
darren / rtp_http.go
Last active December 13, 2023 00:50
最简单的Go代码实现联通的iptv转换为HTTP流, 实现类似udpxy的功能
package main
import (
"flag"
"io"
"log"
"net"
"net/http"
"os"
"strings"
package main
import (
"flag"
"log"
"net"
"net/http"
)
var addr = flag.String("l", ":8000", "Listening address")
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 January 15, 2019 11:50
switch macOS dark mode to prevent iMac image retention
#!/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 / eip.go
Last active December 20, 2017 14:13
Get external IP address (nat-pmp)
package main
import (
"fmt"
"log"
"github.com/jackpal/gateway"
natpmp "github.com/jackpal/go-nat-pmp"
)
@darren
darren / v2ex_daily.go
Created April 27, 2017 04:49 — forked from yinheli/v2ex_daily.go
领取 v2ex 每日奖励 golang
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"regexp"
"strings"
)
@darren
darren / nlc.sh
Last active November 30, 2023 05:04
国家图书馆Wifi自动登录脚本
#!/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)"
# 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