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 / example.sh
Last active Aug 11, 2019
ASCII art with figlet
View example.sh
# brew install figlet
# showfigfonts
# example:
figlet -D -n -f fender "The quick brown fox jumps over the lazy dog [ \ ] { | } ~"
# |''||''| '|| '||
# || || '' ||
# || ||''|, .|''|, .|''||` '|| ||` || .|'', || //`
# || || || ||..|| || || || || || || ||<<
# .||. .|| || `|... `|..|| `|..'|. .||. `|..' .|| \\.
@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 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
}
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
@knugie
knugie / mov2mp4
Created Jan 21, 2017
convert .mov to .mp4 using ffmpeg
View mov2mp4
ffmpeg -i movie.mov -vcodec copy -acodec copy out.mp4
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);
#############################################
@knugie
knugie / vector_cluster.rb
Last active Jun 29, 2016
Cluster vectors by their similarity defined by a tolerance vector
View vector_cluster.rb
require 'matrix'
tolerance = Vector[5, 5, 5]
elements = [Vector[2, 1, 4], Vector[20, 100, 25], Vector[21, 98, 21], Vector[1, 2, 3]]
clusters = []
while(elements.any?)
element = elements.pop
cluster, elements = elements.partition do |elem|
diff = tolerance - (elem - element).map(&:abs)
@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
You can’t perform that action at this time.