Skip to content

Instantly share code, notes, and snippets.

View rokoroku's full-sized avatar
🐳

Youngrok Kim rokoroku

🐳
View GitHub Profile
@rokoroku
rokoroku / install-ffmpeg-amazon-linux.sh
Last active September 15, 2021 04:55 — forked from gboudreau/install-ffmpeg-amazon-linux.sh
How to compile ffmpeg on Amazon Linux (EC2)
#!/bin/sh
# Based on instructions found here: http://wiki.razuna.com/display/ecp/FFMpeg+Installation+on+CentOS+and+RedHat#FFMpegInstallationonCentOSandRedHat-InstallX264
if [ "`/usr/bin/whoami`" != "root" ]; then
echo "You need to execute this script as root."
exit 1
fi
cat > /etc/yum.repos.d/centos.repo<<EOF
@rokoroku
rokoroku / router.tsx
Last active January 2, 2017 02:21
react-router-v3-lazy
// lazy load helper
function lazyComponent(promise: Promise<any>): (nextState: Router.RouterState, callback: (error, component?) => void) => void {
return (nextState, callback) => {
promise.then(
(module) => {
setTimeout(() => callback(null, module.default) && router.setLoading(true), 1000)
},
(error) => callback(error)
);
@rokoroku
rokoroku / easing.js
Created August 23, 2017 06:11 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@rokoroku
rokoroku / ec2_open_pssh_by_instance_tags.sh
Created October 25, 2018 07:45
AWS EC2 - open pssh / xpanes by application tag
TARGET_STAGE="prod"
TARGET_APPLICATION="bot-api"
KEYPAIR_PATH="~/.ssh/keypair.pem"
COMMANDS="pm2 logs all --lines 0"
TARGET_IP_ADDRS="$(aws ec2 describe-instances --filter Name=tag:Application,Values=${TARGET_APPLICATION} Name=tag:Stage,Values=${TARGET_STAGE} --query 'Reservations[].Instances[].[State.Name,InstanceId,PrivateIpAddress]' --output=text | grep running | awk '{print $3}' | tr '\n' ' ';)"
pssh -H "${TARGET_IP_ADDRS}" -x "-oStrictHostKeyChecking=no -i ${KEYPAIR_PATH}" -P "${COMMANDS}"
@rokoroku
rokoroku / Mojave
Created October 29, 2018 04:38
mac os scripts
# Fix blurry fonts on macos mojave
# https://www.reddit.com/r/apple/comments/9ijuft/how_to_fix_blurry_fonts_on_macos_mojave_with/
defaults write -g CGFontRenderingFontSmoothingDisabled -bool NO
@rokoroku
rokoroku / differenceRects.ts
Created June 11, 2020 16:09
Javascript multiple rectangle difference
// Rectangle diff algorithm
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Rectangle_difference
type Rect = Pick<ClientRect, 'top' | 'left' | 'width' | 'height'>;
/**
* Checks if the first rectangle contains the second.
*
* @param rectA first rectangle