Skip to content

Instantly share code, notes, and snippets.

@MarkZhangTW
MarkZhangTW / .tmux.conf
Last active August 6, 2021 23:19
My tmux configuration
# Status Bar Decoration
set-option -g status-style bg=colour22,fg=colour46
set-option -g window-status-style bg=colour28,fg=colour190
# Customizing status bar
set-option -g status-left-length 30
set-option -g status-left "#(echo $USER)@#(echo $HOSTNAME) [#S]"
set-option -g status-right-length 40
set-option -g status-right "%a, %d %b %Y %T %z"
set-option -g status-interval 1
@MarkZhangTW
MarkZhangTW / IGMaskRemover.js
Last active June 13, 2020 04:29
移除 Instagram 圖片前面的髒東西。Remove IG's image mask.
setInterval(() => document.querySelectorAll("._4rbun ~ div").forEach(tag => tag.style.display = "none"), 999)
@MarkZhangTW
MarkZhangTW / Dcard_Image_Downloader.js
Created April 6, 2018 00:58
狄卡圖片下載器。Dcard Image Downloader.
document.querySelectorAll(".GalleryImage_image_3lGzO").forEach(tag => {
let link = document.createElement('a');
link.href = tag.src;
link.download = tag.src;
let e = document.createEvent('MouseEvents');
e.initEvent('click', true, true);
link.dispatchEvent(e);
})
@MarkZhangTW
MarkZhangTW / 12000VB6Simple01.frm
Created April 1, 2019 05:03
電腦硬體裝修 乙級 VB6
' 宣告 在檔案 USBIO.dll 所定義的 "OpenUsbDevice" 函數,有兩個整數參數(VenderID, ProductID),會回傳 True: 代表電路板有連接 False: 代表電路板沒有連接
Private Declare Function OpenUsbDevice Lib "USBIO.dll" (ByVal VenderID As Integer, ByVal ProductID As Integer) As Boolean
' 宣告 在檔案 USBIO.dll 所定義的 "OutDataCtrl" 子程序,有兩個整數參數
Private Declare Sub OutDataCtrl Lib "USBIO.dll" (ByVal Data As Byte, ByVal Control As Byte)
Dim Red As Boolean ' 定義 是否為紅燈亮 的 布林(True or False)變數
Dim LEDs(15) As Integer ' 定義 LED 燈號動作 的 整數陣列
Dim Step As Integer ' 定義 目前在第幾個動作 的 整數變數
Dim StepNumber As Integer ' 定義 有幾個動作 的 整數變數
@MarkZhangTW
MarkZhangTW / auto-next.youtube-playlist.js
Created June 3, 2019 05:04
Go next in youtube playlist every 10 seconds.
window.setInterval(
() => document.dispatchEvent(
new KeyboardEvent('keydown', {'keyCode': 78, 'shiftKey': true})
), 10000
);
@MarkZhangTW
MarkZhangTW / drop.iptables
Last active October 27, 2019 17:34
A bash script for iptables dropping IPs which logged in failed more than 9 times.
#!/usr/bin/env bash
lastb -if /var/log/btmp.1 | awk '{print$3}' | sort | uniq -cd > lastb.log.1
lastb -i | awk '{print$3}' | sort | uniq -cd > lastb.log
cat lastb.log.1 lastb.log | sort -n | awk '$1>9{print$2}' | sort -n > try9s.ip
echo '===== IPs failed more than 9 times ====='
cat try9s.ip
while read ip; do
@MarkZhangTW
MarkZhangTW / permute.R
Created November 27, 2019 10:41
permute a matrix
permute = function (m) t(apply(X = m, MARGIN = 1, FUN = function(v) v[sample(length(v))]))
@MarkZhangTW
MarkZhangTW / detachOtherPkgs.R
Created November 28, 2019 06:31
detach all required packages in R
for (package in sessionInfo()$otherPkgs)
detach(paste0('package:', package$Package), character.only = TRUE)
# or
lapply(X = sessionInfo()$otherPkgs, FUN = function(package)
{ detach(paste0('package:', package$Package), character.only = TRUE)})
@MarkZhangTW
MarkZhangTW / dig.all.sh
Last active March 28, 2020 07:30
bash reverse DNS name with dig
for i in {1..254}; do
lookup=$(dig -x 192.168.0.$i +short);
[[ -z "$lookup" ]] || echo "192.168.0.$(printf %3s $i)" - $lookup;
done
@MarkZhangTW
MarkZhangTW / Update-CF-DNS.ps1
Last active February 1, 2021 13:45
Update CloudFlare DNS records with PowerShell
$CF = @{}
$CF.Endpoint = "https://api.cloudflare.com/client/v4/"
# Replace <API Token> to your CloudFlare API Token
# You can create your API Token from https://dash.cloudflare.com/profile/api-tokens
$CF.APIToken = "Bearer <API Token>"
# Replace <zone id> and <record id>
$CF.UpdateDNSRecord = @{Method = "PUT"; object = "zones/<zone id>/dns_records/<record id>"}
$PublicIP = (Get-NetIPAddress -InterfaceAlias "<Interface Alias>" -AddressFamily IPv4).IPAddress