Skip to content

Instantly share code, notes, and snippets.

Avatar

Christian Köstlin gizmomogwai

View GitHub Profile
View .gitignore
intellij-community
.DS_Store
*.png
@gizmomogwai
gizmomogwai / kitchen.plantuml
Last active Apr 14, 2018
The Kitchen, dish, dishwasher algorithm
View kitchen.plantuml
@startuml
start
note right: Agent enters the kitchen to bring back a dish (e.g. glass, cup, mug, plate, ...)
if (Dishwasher running?) then (yes)
:Put dish into sink;
stop
else (no)
if (Dishwasher full?) then (yes)
if (Dishes in dishwasher clean?) then (yes)
:Put clean dishes back;
@gizmomogwai
gizmomogwai / rt.fish
Created Aug 17, 2015
select one raketask with fzf in the fish shell
View rt.fish
function rt -d "select one rake task"
if rake -T | fzf > $TMPDIR/fzf.result
set fzf_result (cat $TMPDIR/fzf.result | cut -d ' ' -f 2)
set h "rake $fzf_result"
commandline $h
end
end
@gizmomogwai
gizmomogwai / copy-lp-user.fish
Created Dec 2, 2016
fish function to copy lastpass username to the clipboard
View copy-lp-user.fish
function copy-lp-name -d "copy lp name"
if lpass ls | fzf > /tmp/fzf.result
set lp_account (cat /tmp/fzf.result | cut -d ' ' -f 1)
set lp_username (lpass show $lp_account | grep 'Username:' | cut -d ' ' -f 2)
echo -n $lp_username | copy
end
end
@gizmomogwai
gizmomogwai / copy-lp-pass.fish
Last active Dec 2, 2016
fish function to copy a lastpass password to the clipboard
View copy-lp-pass.fish
function copy-lp-pass -d "copy lp pass"
if lpass ls | fzf > /tmp/fzf.result
set lp_account (cat /tmp/fzf.result | cut -d ' ' -f 1)
set lp_pass (lpass show $lp_account | grep 'Password:' | cut -d ' ' -f 2)
echo -n $lp_pass | copy
end
end
@gizmomogwai
gizmomogwai / copy.fish
Created Dec 2, 2016
fish function for copy to clipboard
View copy.fish
function copy -d 'copy to clipboard'
switch (uname)
case Linux
xsel --clipboard --input
case Darwin
pbcopy
case '*'
echo "copy not supported for (uname)"
end
end
@gizmomogwai
gizmomogwai / up.fish
Created May 31, 2016
fish function to combine lpass with fzf and pbcopy
View up.fish
function up -d "lastpass user and password"
if lpass ls | fzf > /tmp/fzf.result
cat /tmp/fzf.result
set account_name (cat /tmp/fzf.result | cut -f 1 -d ' ')
lpass show --username $account_name | pbcopy
read -p 'echo username stored in clipboard ... press return to continue'
lpass show --password $account_name | pbcopy
read -p 'echo password stored in clipboard ... press return to continue'
end
end
@gizmomogwai
gizmomogwai / clone_vmware_image.rb
Created May 3, 2013
Clone a stopped VMWare vm.
View clone_vmware_image.rb
from = ARGV[0]
to = ARGV[1]
puts "copy from #{from} to #{to}"
def run(cmd)
puts "Executing #{cmd}"
if !system(cmd)
raise "error while executing #{cmd}"
end
end
@gizmomogwai
gizmomogwai / structs_vs_classes.d
Created Sep 26, 2011
calloverhead of methods of structs and classes
View structs_vs_classes.d
import std.datetime;
import std.stdio : writeln;
struct HStruct {
size_t c;
void add() {
c = c % 3 +1;
}
size_t get() {
@gizmomogwai
gizmomogwai / gist:1014032
Created Jun 8, 2011
measurement of progresslistener
View gist:1014032
require 'benchmark'
class ProgressListener
def initialize
s = Benchmark.bm do |x|
x.report('ProgressListener.initialize') do
@todo = 0.0
@needed_tasks = {}
Rake::application.top_level_tasks.each do |name|
tasks = find_tasks_for_toplevel_task(name)
tasks.each do |t|