Skip to content

Instantly share code, notes, and snippets.

View KevCui's full-sized avatar
🖤

K̶e̶v̶i̶n̶ KevCui

🖤
View GitHub Profile
@KevCui
KevCui / calibrecli.sh
Last active July 13, 2019 16:25
Send ebook to Kindle using Calibre CLI tools
#!/usr/bin/env bash
#
#/ This scrip will send selected ebook to device
#/ Go to ebook folder created by calibre and run this script
#/
#/ Usage:
#/ ./calibrecli.sh "<ebook_file>" "<device_path>"
set -e
set -u
body { background: #222; color: #e6e6e6; }
a { color: #949494; }
a:link, a:visited { color: #949494; }
a:hover, a:active, a:focus { color: #c7c7c7; }
hr { border-bottom: 1px solid #424242; border-top: 1px solid #222; }
@KevCui
KevCui / jwtDecoder.sh
Last active September 7, 2020 09:08
A Bash script to decode JWT token
#!/usr/bin/env bash
# HOW TO USE:
# ~$ chmod +x jwtDecoder.sh
# ~$ ./jwtDecoder.sh "<JWT token>"
padding() {
# $1: base64 string
local m p=""
m=$(( ${#1} % 4 ))
[[ "$m" == 2 ]] && p="=="
@KevCui
KevCui / hint-dark.css
Created December 12, 2017 21:26
Tridactyl dark theme
span.TridactylHint {
position: absolute;
font-family: sans-serif;
font-size: 12px;
font-weight: bold;
text-transform: uppercase;
color: white;
background-color: #204e8a;
border-color: ButtonShadow;
border-width: 0px;
@KevCui
KevCui / commandline-dark.css
Created December 12, 2017 20:44
Tridactyl dark theme
body {
overflow: hidden;
margin: 0;
}
input {
width: 100%;
padding: 0;
font-family: monospace;
font-size: 9pt;
@KevCui
KevCui / update-tridactyl-conf.sh
Last active July 25, 2021 11:26
A script applies Tridactyl configuration in seconds
#!/bin/bash
# Never heard of Tridctyl? Check this out https://addons.mozilla.org/en-US/firefox/addon/tridactyl-vim/
# This script can apply Tridactyl configuration in seconds:
# Step 1: Modify key bindings and string value in the variable "data" as json format.
# Step 2: ./update-tridactyl-conf.sh <path/storage-sync-v2.sqlite>
if [[ -z $(command -v sqlite3) ]]; then
echo "Command \"sqlite3\" does not exist!"
echo "Downlad: https://sqlite.org/download.html"
exit 1
@KevCui
KevCui / 9gag.py
Created December 10, 2017 14:23
Open 9GAG NSFW image link without login
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Open 9GAG NSFW image link without login
# How to use: 9gag.py "<url>"
import webbrowser
import sys, re
m = re.search('\/\w{7}', sys.argv[1])
link = "http://img-9gag-lol.9cache.com/photo" + m.group(0) + "_460s.jpg"
print(link)
webbrowser.open(link)
@KevCui
KevCui / script-in-html.js
Created December 3, 2017 15:05
Post: Ship PWA Guided by Lighthouse
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('./sw.js')
.then(function(registration) {
console.log("Service Worker Registered", registration);
})
.catch(function(err) {
console.log("Service Worker Failed to Register", err);
})
}
@KevCui
KevCui / sw.js
Created December 3, 2017 15:04
Post: Ship PWA Guided by Lighthouse
self.addEventListener('install', e => {
let timeStamp = Date.now();
e.waitUntil(
caches.open('kevin-blog').then(cache => {
return cache.addAll([
`/`,
`/#blog`,
`/css/uno.min.css`,
`/css/font.min.css`,
`/css/resume.min.css`,
@KevCui
KevCui / manifest.json
Created December 3, 2017 15:01
Post: Ship PWA Guided by Lighthouse
{
"short_name": "Kevin",
"name": "Krazy Kevin",
"icons": [
{
"src":"/images/favicons/android-icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
}
],