Skip to content

Instantly share code, notes, and snippets.

Wolfgang Teuber knugie

  • Leipzig
Block or report user

Report or block knugie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@knugie
knugie / jpg_to_2048.sh
Last active Apr 13, 2019
resize and optimize JPEG images to box-fit 2048x2048 pixels with 80% JPEG quality
View jpg_to_2048.sh
#! /usr/bin/env bash
# brew install imagemagick
# brew install jpegoptim
mkdir 2048
for image in *.[jJ][pP][eE]?[gG]; do
convert $image -resize 2048x2048\> ./2048/$image
jpegoptim --strip-all -q --max=80 ./2048/$image
done
@knugie
knugie / cancelAllRequestAnimFrame.js
Created Oct 10, 2014
cancel all request animation frames
View cancelAllRequestAnimFrame.js
window.cancelRequestAnimFrame = ( function() {
return window.cancelAnimationFrame ||
window.webkitCancelRequestAnimationFrame ||
window.mozCancelRequestAnimationFrame ||
window.oCancelRequestAnimationFrame ||
window.msCancelRequestAnimationFrame ||
clearTimeout
} )();
for (var i = 1; i < 99999; i++) {
@knugie
knugie / solution.rb
Created Sep 2, 2018
How many 3 digit numbers have exactly 3 factors?
View solution.rb
[*100..999].count{ |x| (1..x).count { |i| x % i == 0 } == 3 }
# => 7
View worker_pool.rb
# from https://hspazio.github.io/2017/worker-pool/
SIZED_QUEUE_SIZE = 10
############################################################################
def fib(n)
n < 2 ? n : fib(n-1) + fib(n-2)
end
############################################################################
View ffi_CGDisplayBounds_explained.rb
#!/usr/bin/env ruby
###################################################
## Display screen dimensions in macOS using ruby ##
##################################################
# found https://developer.apple.com/reference/coregraphics/1456395-cgdisplaybounds?language=objc
# --> use CoreGraphics framework
# --> CGRect CGDisplayBounds(CGDirectDisplayID display);
#############################################
View mount-tmp.sh
#!/usr/bin/env bash
size=1024 # MB
mount_point=$HOME/tmp
name=$(basename "$mount_point")
usage() {
echo "usage: $(basename "$0") [mount | umount | remount | check | orphan]" \
"(default: mount)" >&2
}
@knugie
knugie / mts_to_mp4.sh
Last active Oct 2, 2017
Convert (Sony) MTS files to MP4
View mts_to_mp4.sh
ffmpeg -i in.mts -c:v mpeg4 -qscale:v 5 -acodec libmp3lame -b:a 192k out.mp4
@knugie
knugie / reduce_pdf.sh
Created Oct 24, 2013
reduce pdf size
View reduce_pdf.sh
#reduce PDF size
#-dPDFSETTINGS
# /screen
# /ebook
# /printer
# /prepress
gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -sOutputFile=out.pdf in.pdf
View keybase.md

Keybase proof

I hereby claim:

  • I am knugie on github.
  • I am knugie (https://keybase.io/knugie) on keybase.
  • I have a public key whose fingerprint is 4F54 2255 6028 FAFB 7458 E545 4276 8876 DFB2 3E2B

To claim this, I am signing this object:

@knugie
knugie / mp42gif
Created Jan 21, 2017
Generate a gif from an mp4 file
View mp42gif
# Using ffmpeg
ffmpeg -y -i video.mp4 -vf fps=1,scale=600:-1:flags=lanczos,palettegen palette.png
ffmpeg -i video.mp4 -i palette.png -filter_complex "setpts=0.125*PTS,fps=5,scale=600:-1:flags=lanczos[x];[x][1:v]paletteuse" video.gif
# OR
# Using ffmpeg and gifsicle (https://www.lcdf.org/gifsicle/)
ffmpeg -i video.mp4 -s 600x400 -r 3 -f gif - | gifsicle --delay=3 > video.gif
You can’t perform that action at this time.