Skip to content

Instantly share code, notes, and snippets.

View hyjk2000's full-sized avatar

James Shih hyjk2000

View GitHub Profile
@hyjk2000
hyjk2000 / glassdoor-no-hardsell.js
Created July 6, 2022 22:01
Glassdoor No Hardsell
(function () {
const overlay = document.querySelector("#ContentWallHardsell");
overlay.parentNode.removeChild(overlay);
document.body.style.overflow = "visible";
(function (elem, eventType) {
for (const { listener, useCapture } of getEventListeners(elem)[eventType] ||
[]) {
elem.removeEventListener(eventType, listener, { useCapture });
@hyjk2000
hyjk2000 / aws.config
Last active March 25, 2022 03:16
Use AWS Vault with AWS CLI Profiles
[default]
[profile jonsmith]
credential_process=aws-vault exec jonsmith --json --prompt=osascript
[profile dev]
source_profile=jonsmith
region=ap-southeast-2
role_arn=arn:aws:iam::123456789:role/DevRole
@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`)
);
@hyjk2000
hyjk2000 / .env
Last active February 13, 2023 07:40
Pi-hole ✖️ cloudflared
TZ=
INTERFACE=
FTLCONF_LOCAL_ADDR4=
FTLCONF_LOCAL_ADDR6=
WEBPASSWORD=
@hyjk2000
hyjk2000 / combine-images-into-pdf.md
Last active April 12, 2021 07:45
Combine images into PDF with Imagemagick
@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 / 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 / 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 / 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 / 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"