Skip to content

Instantly share code, notes, and snippets.

View hyjk2000's full-sized avatar

James Shih hyjk2000

View GitHub Profile
@hyjk2000
hyjk2000 / userstyle.css
Created February 21, 2020 04:52
Bitbucket Diff Colorblind Mode
:root {
--bbcb-deleted-word: rgb(255, 204, 51);
--bbcb-deleted-line: rgb(255, 238, 186);
--bbcb-added-word: rgb(127, 177, 251);
--bbcb-added-line: rgb(213, 227, 249);
}
.udiff-line.deletion pre.source del,
div[type=del] del {
background-color: var(--bbcb-deleted-word) !important;
@hyjk2000
hyjk2000 / .alacritty.yml
Created February 12, 2020 08:48
Alacritty with Tmux Setup
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
#env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
@hyjk2000
hyjk2000 / remove_orphan_jpg.rb
Created November 11, 2018 10:19
Remove orphan JPG files which are not accompanied with CR2 files
# requires recycle-bin: https://github.com/sindresorhus/recycle-bin
orphan_files = Dir.glob('*.JPG').reject do |jpg_file|
File.exist? "#{File.basename(jpg_file, '.*')}.CR2"
end
puts "Removing #{orphan_files.size} orphan files: "
orphan_files_join = orphan_files.join(' ')
puts orphan_files_join
exec "recycle-bin #{orphan_files_join}"
@hyjk2000
hyjk2000 / password_gen.rb
Created March 21, 2018 03:10
Generate Random Password with SecureRandom
require 'securerandom'
class PasswordGen
ALPHANUMERIC = ((48..57).to_a + (65..90).to_a + (97..122).to_a).pack('c*').freeze
SYMBOL = ((33..47).to_a + (58..64).to_a + (91..96).to_a + (123..126).to_a).pack('c*').freeze
attr_reader :length, :alphanumeric, :symbol
def initialize(length: 20, alphanumeric: true, symbol: true)
@length = length.to_i
@hyjk2000
hyjk2000 / recursive_letters.rb
Last active December 1, 2017 07:00
Recursive Letters with Indentations
def recursive_letters(letters, depth = 0)
character = letters.shift
indentation = ' ' * depth
puts "#{indentation}<#{character}>"
recursive_letters(letters, depth + 1) unless letters.empty?
puts "#{indentation}</#{character}>"
end
@hyjk2000
hyjk2000 / chess_board.rb
Last active May 22, 2017 09:29
Variable Sized ASCII Chess Board
class ChessBoard
attr_accessor :rows, :columns, :square_size
def initialize(rows, columns, square_size)
@rows = rows
@columns = columns
@square_size = square_size
end
def render
@hyjk2000
hyjk2000 / drag-files-here-to-play-in-theater-mode.bat
Last active April 6, 2018 17:08
My mpv configuration including profiles for playing on HDTV and Home Theater Amplifier
@echo off
mpv --profile=theater %1
@hyjk2000
hyjk2000 / forward.conf
Last active December 27, 2023 17:56
Unbound Stub Zones to Prevent Resolving CDN Domains with Google DNS
# Resolving internal domains
local-zone: "local." static
local-data: "example.local. IN A [Internal Server IP]"
# Stub out CDN domains to use local DNS provided by your ISP
stub-zone:
name: "akadns.net"
stub-addr: [Local DNS IP]
@hyjk2000
hyjk2000 / dft_example.rb
Created August 18, 2016 06:16
Depth-first traversal on a hash
h = {
foo: {
bar: {
baz: 1
},
oof: {
zab: 2
}
},
zha: {
@hyjk2000
hyjk2000 / wechat_auth_hash.json
Created August 18, 2016 05:55
auth_hash example of omniauth-wechat-oauth2
{
"credentials": {
"expires": true,
"expires_at": 1436019773,
"refresh_token": "[hidden]",
"token": "[hidden]"
},
"extra": {
"raw_info": {
"city": "Xi'an",