Skip to content

Instantly share code, notes, and snippets.

View arlimus's full-sized avatar

Dominik Richter arlimus

View GitHub Profile
@arlimus
arlimus / Christmas songs
Last active December 24, 2022 09:07
Guess the song (German and English)
⏪🎄
🤫🌃👼🌃
0🎄
🔴👃🏽🦌
❄⚪👗
🤫🌨
0😀
🧒🏽🧒🏻🏃🏽‍♂️
🚗🏡4🎄
🛎🔔🛎🛎
@arlimus
arlimus / essential vim
Last active November 17, 2017 16:23
vim.essential.md
Personal most used commands in vim (VSCode, Atom, ... any editor really)
# motion.txt
y c d ... yank / change / delete
v V ... visual mode character-wise/Line-wise
< > ... indent and outdent
/ ? ... search forward or backwards,
eg "/word" => go to "word"
@arlimus
arlimus / compare_versions1.rb
Last active August 29, 2015 13:59
Compare package versions. Correctly handles numbers and letters.
# usage: provide a list (Array) of package objects
# package.version must contain the version string, e.g. "1.0.0e-1ubuntu3.4"
# Method 1: simple
# blow up all numbers
def sort_packages list
list.map do |x|
[ x, x.version.gsub(/[0-9]+/){|z| "%010x" % z} ]
end.
sort{|x,y| x[1] <=> y[1]}.
@arlimus
arlimus / sequel-kaminari.rb
Created April 10, 2014 20:54
Tiny helper to make Sequel look like kaminari to api-pagination.
# usage example with Grape:
#
# require 'kaminari'
# require 'sequel-kaminari'
# require 'api-pagination'
# ...
# desc "Get all items"
# paginate per_page: 25
# get :items do
# paginate( DB[:items] ).all.map(&:to_hash)
@arlimus
arlimus / gitlab-28-to-64.sh
Last active January 2, 2016 21:39
Upgrading gitlab data from caveman to modern age.
## prerequisite:
## deploy https://github.com/ogom/cookbook-gitlab
## have repos in place (/home/git/repositories)
## have data in mysql
service gitlab stop
# we need ruby1.9.1 for old gitlab migration...
apt-get install -y libpq-dev ruby1.9.1 ruby1.9.1-dev
update-alternatives --set ruby /usr/bin/ruby1.9.1
@arlimus
arlimus / ssh tunnelling vagrant env
Last active November 17, 2017 16:09
Experiment with remote SSH tunnels and forwarding. Vagrant environment. See http://arlimus.github.io/articles/ssh.reverse.tunnel.security
# -*- mode: ruby -*-
# vi: set ft=ruby :
name = 'saucy'
IP = {
'saucy' => '192.168.123.123',
'client1' => '192.168.123.101',
'client2' => '192.168.123.102'
}
@arlimus
arlimus / git-tricks.sh
Created October 4, 2013 10:00
Git tricks
# get the SHA hash of the first commit in your git repo
git log --pretty=format:%H | tail -n1
# put version 0.0 tag onto the first commit in your git repo
git tag 0.0 $(git log --pretty=format:%H | tail -n1 )
@arlimus
arlimus / print_characters.rb
Last active December 24, 2015 12:39
Find your favorite unicode character quickly, print them to console
# define the printer
def p_uni(range); r = Array(range); return if r.empty?; puts r[0..79].pack("U*").gsub(/\p{^Print}/,''); p_uni(r[80..-1]); end
# use it
p_uni(0x30..0x2e50)
# this will give you:
# 0123456789:;<=>?@ABCDEFGHIJKLMNO...
# ...
# ⸠⸡⸢⸣⸤⸥⸦⸧⸨⸩⸪⸫⸬⸭⸮
@arlimus
arlimus / minify.rb
Created August 21, 2013 17:30
Minify images (jpg/png) in the current folder to smaller sizes (up to ~350k). Example run: > minify -- converting with quality 70, resize 100% 134 (25).png -- converting with quality 70, resize 100% -- converting with quality 70, resize 84% 144 .jpeg > ll minified -rw-r--r-- 1 zhaery users 130K 21. Aug 19:33 134 (25).png.jpg -rw-r--r-- 1 zhaery …
#!/usr/bin/env ruby
require 'fileutils'
threshold = 350e3
$output = "minified"
$quality = 70
FileUtils.mkdir_p $output
def conv org, factor = 1.0
puts "-- converting with quality #{$quality}, resize #{(factor*100).round}%"
@arlimus
arlimus / gitconfig
Last active May 17, 2021 18:36
my gitconfig configuration
# git config; arlimus, public domain
## Make your adjustments
########################
[user]
name = Your Name
email = your.name@email.com
[core]