Skip to content

Instantly share code, notes, and snippets.

View hyjk2000's full-sized avatar

James Shih hyjk2000

View GitHub Profile
@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 / 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 / v2gif
Last active March 5, 2020 21:30
Video to GIF with FFMPEG
#!/usr/bin/env bash
# Usage: v2gif video.mov video.gif
ffmpeg -i "$1" -vf "fps=5,scale=640:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 "$2"
@hyjk2000
hyjk2000 / exponentiation_by_squaring.rb
Created June 2, 2020 02:48
Exponentiation by Squaring
# frozen_string_literal: true
require 'benchmark'
def repeat_naive(str, num)
result = ''
str = str.to_s
num = num.to_i
while num.nonzero?
result += str
@hyjk2000
hyjk2000 / tarpit.js
Created February 7, 2021 09:05
Node.js Tarpit Server
const http = require("http");
const server = http.createServer((req) => {
console.info(`${new Date()} ${req.method} ${req.url}`);
});
server.listen(8080);
@hyjk2000
hyjk2000 / to_base64.rb
Created February 7, 2021 09:07
File to Base-64
require 'base64'
print Base64.encode64(File.open(ARGV.first, 'rb').read).gsub(/\s/, '')
@hyjk2000
hyjk2000 / ffmpeg-batch-recursive
Last active March 25, 2021 11:09
FFmpeg batch convert files in recursive directories
#!/usr/bin/env bash
# parallel runs in N-process batches
# https://unix.stackexchange.com/a/216475
N=4
# enable globstar, requires bash >=4.0
shopt -s globstar
for f in ../iTunes\ Media/**/*.m4a; do
@hyjk2000
hyjk2000 / combine-images-into-pdf.md
Last active April 12, 2021 07:45
Combine images into PDF with Imagemagick
@hyjk2000
hyjk2000 / .env
Last active February 13, 2023 07:40
Pi-hole ✖️ cloudflared
TZ=
INTERFACE=
FTLCONF_LOCAL_ADDR4=
FTLCONF_LOCAL_ADDR6=
WEBPASSWORD=
@hyjk2000
hyjk2000 / aws-ssm-env.js
Created October 12, 2021 01:46
Load environment variables from AWS SSM for local development
const { execSync, spawn } = require('child_process');
const AWS_PROFILE = process.argv[2];
const PARAMETERS_PATH = '/path/to/env/';
const { Parameters: params } = JSON.parse(
execSync(`aws --profile ${AWS_PROFILE} ssm get-parameters-by-path --path "${PARAMETERS_PATH}" --with-decryption`)
);