Skip to content

Instantly share code, notes, and snippets.

View LeiHao0's full-sized avatar
😃
I may be slow to respond.

Lei Hao LeiHao0

😃
I may be slow to respond.
View GitHub Profile
@LeiHao0
LeiHao0 / image2pdf.sh
Last active May 12, 2019 06:28
image2pdf
for d in */;
do
cd "$d"
convert *.* tmp.pdf
name=$(echo "$d" | cut -d '/' -f1).pdf
mv tmp.pdf "../$name"
cd -
done
@LeiHao0
LeiHao0 / Surge conf to yml
Last active February 12, 2019 03:56
Auto convert surge conf to clash yml
# 2019-02-11
import os
import re
os.system('curl https://xxx -o proxy.conf')
os.system('curl https://r0uter.github.io/ss.conf-for-surge/geoip_whitelist.conf -o geoip_whitelist.conf')
DNS = 'dns:\n enable: true\n ipv6: false\n nameserver:\n - 1.2.4.8\n - 114.114.114.114\n - 223.5.5.5\n - tls://dns.rubyfish.cn:853\n fallback:\n - 1.1.1.1\n - tls://dns.rubyfish.cn:853\n - tls://dns.google'
ExtralList = '# Apple\n- DOMAIN,hls.itunes.apple.com,Proxy\n- DOMAIN,itunes.apple.com,Proxy\n- DOMAIN-SUFFIX,digicert.com,DIRECT\n- DOMAIN-SUFFIX,icloud.com,DIRECT\n- DOMAIN-SUFFIX,icloud-content.com,DIRECT\n- DOMAIN-SUFFIX,mzstatic.com,DIRECT\n- DOMAIN-SUFFIX,akadns.net,DIRECT\n- DOMAIN-SUFFIX,aaplimg.com,DIRECT\n- DOMAIN-SUFFIX,cdn-apple.com,DIRECT\n- DOMAIN-SUFFIX,apple.com,DIRECT\n# LAN\n- DOMAIN-SUFFIX,local,DIRECT\n- IP-CIDR,127.0.0.0/8,DIRECT\n- IP-CIDR,172.16.0.0/12,DIRECT\n- IP-CIDR,192.168.0.0/16,DIRECT\n- IP-CIDR,10.0.0.0/8,DIRECT\n- IP-CIDR,17.0.0.0/8,DIRECT\n- IP-CIDR,100.64.0.0/10,DIREC
@LeiHao0
LeiHao0 / embedSub.sh
Last active August 2, 2018 02:28
embedSub.sh
#!/bin/zsh
mkdir -p embedSub
files=$(ls -1 | grep mkv)
for f in *.mkv; do
echo "$f"
ffmpeg -nostats -loglevel 0 -y -i "$f" -vf subtitles="$f" "embedSub/$f";
done
@LeiHao0
LeiHao0 / Coursera - Estimated Time
Last active January 5, 2018 03:52
Estimate the rest time of each course on its Coursera Welcome page to do a better Scrum
// ==UserScript==
// @name Coursera - Estimated Time
// @namespace http://tampermonkey.net/
// @version 0.4
// @description Estimate the rest time of each course on its Coursera Welcome page to do a better Scrum
// @author Artwalk
// @source https://gist.github.com/Artwalk/18b594172c7b0b71f2bb210788b3939a
// @include https://www.coursera.org/learn/*/home/welcome
// @match https://www.coursera.org/learn/*/home/welcome
// @grant none
@LeiHao0
LeiHao0 / crontab.sh
Last active May 24, 2016 06:38
sendMessage.applescript
crontab -e
0-59 0-23 1-31 1-12 0-7 osascript /Users/Art/Desktop/sendMessage.applescript $PhoneNumber "Text Message"
@LeiHao0
LeiHao0 / DuplicateFiles.rb
Created April 20, 2016 03:29
Find duplicate Files (file < 4G)
#!/usr/bin/env ruby
# Usage
# ruby DumpFiles.rb ~/$DirPath
require 'digest/md5'
require 'find'
path = ARGV[0]
path = './' if !path
@LeiHao0
LeiHao0 / init.sh
Last active November 28, 2017 15:37
UpdateBrewDaily
ln -s $Path/AutoUpdateBrew/launchd.plist ~/Library/LaunchAgents/sh.brew.update
launchctl load ~/Library/LaunchAgents/sh.brew.update
@LeiHao0
LeiHao0 / FlooNetworkRequestGenerator
Last active December 21, 2015 04:29
Auto Generator FlooNetwork Request
$url = "api/show"
$prefix = "TF"
def className
refineStr = $url.gsub("api", '')
a , b = refineStr.split('/')
return $prefix + a.capitalize + b.capitalize
end
@LeiHao0
LeiHao0 / GetAllImagesUrl
Created December 11, 2015 08:10
get All Images Url of a webpage
var list=[];
var a=document.getElementsByTagName('img');
for (var i=0,l=a.length;i<l;i++)
{
if (/\.(jpg|gif|png|jpeg)$/im.test(a[i].getAttribute('src')))
{
list.push(a[i].getAttribute('src'));
}
}
@LeiHao0
LeiHao0 / ExchangeNames
Created July 15, 2015 08:31
exchange people's First and Last Name in Mac OSX Contacts
import AddressBook
let addressBook = ABAddressBook.sharedAddressBook()
let firstKey = "First"
let lastKey = "Last"
for people in addressBook.people() {
if let p = people as? ABPerson {
let f: AnyObject? = p.valueForKey(firstKey)