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:
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) |
#!/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); | |
############################################# |
ffmpeg -i movie.mov -vcodec copy -acodec copy out.mp4 |
# 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 |
I hereby claim:
To claim this, I am signing this object:
#!/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 | |
} |
# 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 | |
############################################################################ |
[*100..999].count{ |x| (1..x).count { |i| x % i == 0 } == 3 } | |
# => 7 |
# brew install figlet | |
# showfigfonts | |
# example: | |
figlet -D -n -f fender "The quick brown fox jumps over the lazy dog [ \ ] { | } ~" | |
# |''||''| '|| '|| | |
# || || '' || | |
# || ||''|, .|''|, .|''||` '|| ||` || .|'', || //` | |
# || || || ||..|| || || || || || || ||<< | |
# .||. .|| || `|... `|..|| `|..'|. .||. `|..' .|| \\. |
# From https://tjay.dev/howto-working-efficiently-with-large-files-in-ruby/ | |
# Encrypt | |
cipher = OpenSSL::Cipher::AES256.new(:CBC) | |
cipher.encrypt | |
cipher.key = KEY | |
cipher.iv = IV | |
file = nil | |
enc_file = nil |