Skip to content

Instantly share code, notes, and snippets.

View simplesessions's full-sized avatar
💭
Busy, busy, busy!

Charles Kihe simplesessions

💭
Busy, busy, busy!
View GitHub Profile
@simplesessions
simplesessions / convert-yt-timestamp.js
Created June 2, 2020 23:54
convert-yt-timestamp.js
const str = '2m20s'
const seconds = str.split(/(\d+\D)/ig).filter(n => n).map(s => s.split(/(\d+)/).filter(n => n)).reduce((acc, curr) => {
let sec = acc
if (curr[1] === 's') {
sec += parseInt(curr[0])
}
if (curr[1] === 'm') {
sec += parseInt(curr[0]) * 60
}
@simplesessions
simplesessions / ssl-certbot.sh
Last active February 7, 2020 02:47
Certbot SSL
#ref: https://serverfault.com/questions/750902/how-to-use-lets-encrypt-dns-challenge-validation
sudo certbot -d domain --manual --agree-tos --preferred-challenges dns certonly
@simplesessions
simplesessions / gif2mp4.sh
Created December 9, 2019 18:18
Convert animated GIF to Video with FFMpeg
ffmpeg -i animated.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" video.mp4
ffmpeg -i input.mp3 -codec:a libmp3lame -qscale:a 5 output.mp3
@simplesessions
simplesessions / config.json
Last active April 20, 2018 21:35
My VSCode Config
{
"editor.fontSize": 11,
"editor.fontFamily": "'Source Code Pro', Menlo, Monaco, 'Courier New', monospace",
"editor.tabSize": 2,
"files.exclude": {
"**/.vscode": true,
"**/.storybook-dist": true,
"**/.cache": true,
"node_modules": true,
"**/.git": true,
@simplesessions
simplesessions / gifsicle.sh
Last active November 13, 2017 18:55
Gifsicle: Frames & Timing
gifsicle -d 12 -U input.gif `seq -f "#%g" 0 4 82` -O2 -o output.gif
# ^ timing ^ output
# ^ input file ^ start frame, every other, end frame
@simplesessions
simplesessions / compress_jpgs.sh
Last active July 5, 2017 07:55
Recursively compress JPGs
# Ref: https://guides.wp-bullet.com/batch-optimize-jpg-lossy-linux-command-line-with-jpeg-recompress/
# Run a quality check against each image, then compress using the best settings
brew install mozjpeg
find [path/to/images] -type f -iname '*.jpg' -exec jpeg-recompress --quality medium --min 60 --method smallfry \{} \{} \;
# Remove metadata from images
brew install exiftool
find [path/to/images] -type f -iname "*.jpg" -exec exiftool -overwrite_original -all= \{} \;
find . -name "*.t1" -exec rename 's/\.t1$/.t2/' '{}' \;
@simplesessions
simplesessions / .bashrc
Created March 14, 2017 21:57
Server bash.rc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@simplesessions
simplesessions / sublime-settings.json
Created February 2, 2017 19:04
My Sublime Settings
{
"binary_file_patterns":
[
"*.jpg",
"*.jpeg",
"*.png",
"*.gif",
"*.ttf",
"*.tga",
"*.dds",