Skip to content

Instantly share code, notes, and snippets.

View twinsant's full-sized avatar
💭
Coding

Atman An twinsant

💭
Coding
View GitHub Profile
@twinsant
twinsant / netstat.sh
Created November 20, 2023 02:36
Mac netstat
lsof -iTCP -sTCP:LISTEN -n
@twinsant
twinsant / al.sh
Last active November 12, 2023 10:27
Sum videos length in current dir
# alias vlen='f(){ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$@"};f'
find . -type f|grep mp4 | xargs -L 1 ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1|awk '{s+=$1} END {print s}'
@twinsant
twinsant / cocos.d2
Last active January 4, 2023 04:20
Cocos Creator
Node: {
shape: class
runAction()
}
ComponentJS: {
shape: class
onLoad()
onEnable()
@twinsant
twinsant / up
Last active March 8, 2023 02:31
Upwork view helper.
// ==UserScript==
// @name Upwork tool
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author twinsant
// @match https://www.upwork.com/nx/find-work/best-matches
// @icon https://www.google.com/s2/favicons?sz=64&domain=upwork.com
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jshashes/1.0.8/hashes.min.js
@twinsant
twinsant / tm.js
Last active November 7, 2022 10:28
Tampermonkey script for focus input.
// ==UserScript==
// @name Focuse input
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://eth-converter.com/
// @icon https://www.google.com/s2/favicons?sz=64&domain=eth-converter.com
// @grant none
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js
@twinsant
twinsant / bot.sh
Created September 30, 2022 03:37
Update nginx ssl
# Check argument
if [ -z $1 ]; then
echo Need a domain name.
exit 1
fi
# Move and unzip
downlaodfile=~/Downloads/$1_nginx.zip
zipfile=$1_nginx.zip
crtfile=$1_bundle.crt
@twinsant
twinsant / px.sh
Last active September 29, 2022 06:13
Change Mac system proxy
if [ {query} = "on" ]; then
networksetup -setsocksfirewallproxy wi-fi localhost 9001
networksetup -setsocksfirewallproxystate wi-fi on
echo "Proxied"
else
networksetup -setsocksfirewallproxystate wi-fi off
echo "No proxy"
fi
@twinsant
twinsant / get_cd.sh
Last active November 9, 2022 06:11
Update chromedriver version
version=107.0.5304.62
wget -O ~/dl/cd.zip https://chromedriver.storage.googleapis.com/$version/chromedriver_mac64.zip
unzip ~/dl/cd.zip -d ~/bin/
@twinsant
twinsant / ocr.py
Created November 9, 2021 05:14
Pythonista Text OCR example.
import photos
import objc_util
VNImageRequestHandler = objc_util.ObjCClass('VNImageRequestHandler')
VNRecognizeTextRequest = objc_util.ObjCClass('VNRecognizeTextRequest')
def text_ocr(asset):
img_data = objc_util.ns(asset.get_image_data().getvalue())
with objc_util.autoreleasepool():
@twinsant
twinsant / ocr.swift
Last active November 8, 2021 09:07
Text OcR
// Hacked from: https://stackoverflow.com/questions/44533148/converting-a-vision-vntextobservation-to-a-string
// Ref: https://developer.apple.com/videos/play/wwdc2019/234/
import Vision
import UIKit
class OCRReader {
func performOCR(recognitionLevel: VNRequestTextRecognitionLevel) {
let image = #imageLiteral(resourceName: "Hello.JPG")
let requestHandler = VNImageRequestHandler(cgImage: image.cgImage!, options: [:])