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 / 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){
@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
@knugie
knugie / git_hub_pretty_print_markdown_bookmarklet.txt
Created Jan 28, 2016
Bookmarklet to pretty-print GitHub markdown file
View git_hub_pretty_print_markdown_bookmarklet.txt
javascript:(function(e,a,g,h,f,c,b,d)%7Bif(!(f=e.jQuery)%7C%7Cg>f.fn.jquery%7C%7Ch(f))%7Bc=a.createElement("script");c.type="text/javascript";c.src="http://ajax.googleapis.com/ajax/libs/jquery/"+g+"/jquery.min.js";c.onload=c.onreadystatechange=function()%7Bif(!b&&(!(d=this.readyState)%7C%7Cd=="loaded"%7C%7Cd=="complete"))%7Bh((f=e.jQuery).noConflict(1),b=1);f(c).remove()%7D%7D;a.documentElement.childNodes%5B0%5D.appendChild(c)%7D%7D)(window,document,"1.3.2",function($,L)%7B$('%23header, .pagehead, .breadcrumb, .commit, .meta, %23footer, %23footer-push, .wiki-actions, %23last-edit, .actions, .header,.site-footer,.repository-sidebar,.file-navigation,.gh-header-meta,.gh-header-actions,#wiki-rightbar,#wiki-footer,.commit-tease').remove();%20$('%23files,%20.file').css(%7B%22background%22:%22none%22,%20%22border%22:%22none%22%7D);%20$('link').removeAttr('media');%7D); var removeMe = document.getElementsByClassName("file-header")[0]; removeMe.parentNode.removeChild(removeMe);
@knugie
knugie / AES-256-CBC-sample.rb
Last active Jan 28, 2016
AES - symmetric algorithms for encryption and decryption
View AES-256-CBC-sample.rb
require 'openssl'
require 'digest/sha2'
# Config
alg = "AES-256-CBC"
# Key
key = OpenSSL::Cipher::Cipher.new(alg).random_key
# Init Digest
@knugie
knugie / .zshrc
Last active Jan 3, 2016
# Use alt+arrow to move cursor by word# Mac OS X El Capitan # iTerm2 # zsh # ~/.zshrc
View .zshrc
# Use alt+arrow to move cursor by word
# https://gist.github.com/knugie/fc9964695951b4c13ed3
# Mac OS X El Capitan # iTerm2 # zsh
# ~/.zshrc
bindkey -e
bindkey '\e\e[C' forward-word
bindkey '\e\e[D' backward-word
View wget_entire_site.md
@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
You can’t perform that action at this time.