Skip to content

Instantly share code, notes, and snippets.

View jostyee's full-sized avatar
💭
脑壳疼

Josta Yee jostyee

💭
脑壳疼
  • Singapore
View GitHub Profile
@jostyee
jostyee / goodreads_to_book_track.py
Created August 5, 2020 08:44 — forked from ahmedre/goodreads_to_book_track.py
Goodreads export to Book Track friendly Importer
import csv
import requests
import sys
"""
This script converts a Goodreads export csv into a Book Track friendly csv.
It does this by querying Google Books' api for each book and adding its id,
along with removing some of the other unnecessary fields in the original
export.
@jostyee
jostyee / go.xml
Created July 11, 2020 12:52 — forked from sha1sum/go.xml
GOlang File Format for Beyond Compare
<?xml version="1.0" encoding="UTF-8"?>
<!-- Produced by Beyond Compare 4 from Scooter Software -->
<!--
This is an extension of the work done by Nate Finch:
https://npf.io/2014/05/diffing-go-with-beyond-compare/
The regular expressions for identifiers have been updated
to match on lowercase and allow numbers to be included anywhere
after the first character of the word.
@jostyee
jostyee / pi.status.sh
Created May 16, 2020 14:38 — forked from dchakro/pi.status.sh
Shell script to print stats about a Raspberry running pihole
# Gather system details.
dt=$(date -R)
freq=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq)
volts=$(sudo /opt/vc/bin/vcgencmd measure_volts)
temp=$(sudo /opt/vc/bin/vcgencmd measure_temp)
gov=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
up=$(uptime)
# Print System details
echo " "
@jostyee
jostyee / karabiner_merge.sh
Created June 11, 2019 14:53 — forked from narze/karabiner_merge.sh
Merge karabiner.json with complex modification rules
#!/usr/bin/env bash
# Requirements : goku, jq
# 1. Make sure goku runs
goku
# 2. Make temp json file
cp ~/.config/karabiner/karabiner.json ~/.config/karabiner/karabiner.tmp.json
.frontbg {
background-color: #53cd80;
border-radius: 7px;
color: #fff;
position: relative;
left: 0;
}
.android .frontbg {
background-color: #eelf34;
border-radius: 7px;
#!MANAGED-CONFIG https://gist.githubusercontent.com/jostyee/561076f741d93b9c5c2924328d9d1cb6/raw/surge-cn.conf interval=259200 strict=true
[General]
loglevel = notify
skip-proxy = 127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, localhost, *.local, ::ffff:0:0/96
ipv6 = false
allow-wifi-access = false
dns-server = 114.114.114.114, 223.5.5.5, system
external-controller-access = pwd@0.0.0.0:6155
@jostyee
jostyee / gist:3f0e8185c394fe207b286282d50bb3ea
Created January 18, 2018 10:06 — forked from Blankwonder/gist:cd9fa1987e41cf1a1f1df50583ba1d9c
client-side SSL/TLS certificate validation
[Proxy]
TestTLS = https, 192.168.20.6, 443, client-cert=item
[Keystore]
item = password=123456, base64=MIILqQIBAzCCC28GCSqGSIb3DQEHAaCCC2AEggtcMIILWDCCBg8GCSqGSIb3DQEHBqCCBgAwggX8AgEAMIIF9QYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIh4LPGCPkcqkCAggAgIIFyDOP/a/YB66H0jctVC5/D3ZF98es9Xtf60hqDokaekMp7VlKhr7EEvf1GrmxOY9XqO1dSR0F2C17yefazR7lZVDwfmNvU8eEpIPrBAnqSnCFyMZGXjcu9aoEySkwRlSclqg9lbFhp9XZG4F4qRuo94mlTPDy47dvdzyiPAQPBIq2DOE/qbRVHqrbnZMkUZi1lxihRRcQv7YJAfLEP2VHffjZTYzlBMi/ldKyD4ZQdpM7mdBtHXFa21ZV9j4oqM2PWWToHwIxkeiS6J2SgfEg501QEy4kbihlp+pSK4OMrj33DrVFP9rOMDnkJtQ+EP0LXXQBaF+7rRp+dekcH+sYBQF0cDMhNEkHEBL8LoQ96hZxIDxE3YQ6fq9KGi4TV8Ktkgb2l0G5DoavN8dhCKS5Gx0nexDT8vj91Js94Xt4tFThSyoc4ZmZvN+b2ugqVvYsnWaKqS8UeAjIAFsZCiLgj4OG6frrAxI+V3c8kL9FrwfFQcL9eWoqVfhBv8SKzMYObTv9FwyJn/fyGdtoT19OpyWiP1+nU+WY7e5KjcJNsKeYolgpgHDXdOSYCakQfesENeeKqvzMA6Quj7g7gZl/AB/GjRybyAXfkxyYBLk5cz7MuDcM1nk6DR47IuHBHyrwOATXyejWYrlK0QUVUsFEmM2vjl38jU8+qxjVWDTFu3gQkFBERncJp1XnKSTueDEPkdeq1BzV1SZ1m1KHNPNI4h2lPa+IKvpYbnDure9n1VV7fk2ySJrBFT5pYonXdpyaCTAvTEFk
@jostyee
jostyee / GoConcurrency.md
Created October 24, 2017 06:30 — forked from rushilgupta/GoConcurrency.md
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

# set tab title to cwd
# If the working directory is part of a git project, it sets the window title to the project top level directory path, and the tab title to the project top level directory name.
# Otherwise uses de relative path.
function precmd() {
if command git rev-parse --git-dir > /dev/null 2>&1; then
window_label=$(git rev-parse --show-toplevel)
tab_label=$(echo $window_label | awk -F\/ '{print "[git] " $NF}')
else
window_label=${PWD/${HOME}/\~}
tab_label=$window_label
@jostyee
jostyee / set-title-tab.zsh
Created October 16, 2017 10:01 — forked from capotej/set-title-tab.zsh
sets title tab intelligently in zsh/iterm2
#!/bin/zsh -f
# This is the successor to settab and settitle functions (as well as the chpwd function).
# It avoids the explicit definition and use of special functions such as
# chpwd, precmd, preexec, instead setting appropriate arrays. This is to prevent conflicts
# with user's prompt functions and so forth.
# This is designed to put by default the computer name and whole directory path
# into the title bar (and if availble) the $PWD and penultimate directory
# in the tab. Also enables transient display of a running command (eg vim).