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 / 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
@knugie
knugie / install_makemkv.sh
Last active Nov 23, 2016
Ubuntu - Install MakeMKV 1.9.0
View install_makemkv.sh
sudo apt-get install build-essential pkg-config libc6-dev libssl-dev libexpat1-dev libavcodec-dev libgl1-mesa-dev libqt4-dev
wget http://www.makemkv.com/download/makemkv-oss-1.9.0.tar.gz
wget http://www.makemkv.com/download/makemkv-bin-1.9.0.tar.gz
tar -xvf makemkv-oss-1.9.0.tar.gz
tar -xvf makemkv-bin-1.9.0.tar.gz
cd makemkv-oss-1.9.0/
./configure
make
sudo make install
@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 / poc_meter.rb
Created Jun 24, 2016
POC type checking when calculating with unit-based values
View poc_meter.rb
class Meter
attr_reader :value, :unit
def initialize(value, unit = 'm')
@value = value
@unit = unit
end
def self.[](value)
self.new(value)
@knugie
knugie / keyboard_layout_switcher
Created Jun 20, 2016
Keyboard layout switcher - Xcode project (objective-c, command line tool)
View keyboard_layout_switcher
//
// main.m
// keyboard_layout_switcher
//
@import Carbon;
int main(int argc, const char * argv[]) {
@autoreleasepool {
if (argc <= 1){
View bit_count_benchmark.rb
#!/usr/bin/env ruby
# coding: utf-8
require 'benchmark'
@count = 2_000_000
@lenght = 49
@pre_compute_16 = Array.new((2**16)) { |f| f.to_s(2).count('1') }
Strategy = Struct.new(:name, :method, :before)
@knugie
knugie / cluster.rb
Created Mar 25, 2016
Cluster numbers by their distance to each other
View cluster.rb
values = 20.times.map{rand(100)+200}
delta = 10
min, max = values.minmax
offset = min - delta / 2
grouped = values.group_by { |value| (value - offset) / delta }
Hash[grouped.sort]
=begin
View count_unique_elements_in_array.rb
require 'benchmark'
require 'open3'
require 'histogram/array'
array = Array.new(10_000_000) { rand(60) }
puts 'uniq, count:'
uniq_count = Benchmark.measure do
array.uniq.map { |key| array.count(key) }
end
@knugie
knugie / count_files.sh
Created Feb 5, 2016
List number of files in each directory
View count_files.sh
find -P . -type f | rev | cut -d/ -f2- | rev | cut -d/ -f1-2 | cut -d/ -f2- | sort | uniq -c
You can’t perform that action at this time.