Skip to content

Instantly share code, notes, and snippets.

View ferki's full-sized avatar
🆓
I accept new customers

Ferenc Erki ferki

🆓
I accept new customers
View GitHub Profile
@ferki
ferki / perltest.vim
Last active March 29, 2016 14:38
Run Perl test from vim
" perltest.vim - test driven development for Perl with vim
"
" ,t -- Run tests
" ,w -- Set current file as test file. Only this test will run.
" ,W -- Unset current test file. All tests will run.
"
" v1.02 - Updates at http://perlmonks.org/index.pl?node_id=434793
function! Prove ( verbose, silent )
if ! exists("g:testfile")
@ferki
ferki / lockscreen.sh
Created August 2, 2014 18:00
lockscreen
#!/bin/sh
#check if i3lock is already running
pgrep i3lock > /dev/null && exit 1
#make screenshot
scrot ~/lockscreen.png
#apply blur
mogrify -filter Gaussian -resize 20% -define filter:sigma=1 -resize 500% ~/lockscreen.png
#mogrify -blur 0x8 ~/lockscreen.png
@ferki
ferki / ftplugin_perl.vim
Last active March 29, 2016 14:40
vim-perltidy
fun! Tidy()
silent exe ":update"
let pos1 = line(".")
exe '%!perltidy'
exe ':'.pos1
endfun
autocmd BufWrite *.t,*.pm,*.pl,Rexfile call Tidy()
if exists("b:did_spell")
@ferki
ferki / scrocr
Created March 25, 2015 06:07
Copy text from screenshot to clipboard
#!/bin/sh
IMAGE="/tmp/scrocr.png"
scrot -s ${IMAGE}
mogrify -modulate 100,0 -resize 400% ${IMAGE}
tesseract ${IMAGE} stdout | xsel -bi
rm ${IMAGE}
use Rex -feature => ['1.0'];
use Rex::Commands::Virtualization;
use Data::Dumper;
#parallelism 10;
use Rex::Group::Lookup::INI;
groups_file "hosts.ini";
user "root";
@ferki
ferki / rex.vim
Last active October 27, 2016 14:47
Rex highlighting for vim
# put this file into ~/.vim/after/syntax/perl/rex.vim and then remove this line
syn keyword perlStatementScalar after after_task_finished before before_task_start bios_boot cache cat case checkout command content create_home delete_lines_according_to delete_lines_matching do_task desc download ensure extract group groups_file home initialize is_dir is_file is_symlink key_auth line LOCAL mode needs no_overwrite on_change on_rollback only_if options owner parallelism partition pass_auth password path private_key public_key regexp report repository rm sayformat share size source ssh_key sudo sudo_password transaction type umount unless unlink update_package_db update_system user upload
syn keyword perlStatementList account append_if_no_such_line append_or_amend_line batch chgrp chmod chown clearpart cmdb cp create_user cron_entry file get i_run ln mount mv pkg run run_task say sed service symlink task template
syn keyword perlStatementHash environment set
syn keyword perlString FALSE
@ferki
ferki / Rexfile
Created May 29, 2015 12:07
initialize as root, setup as normal user
use Rex -base;
user 'deployer';
password 'userpass';
sudo_password 'userpass';
sudo TRUE;
auth for => initialize =>
user => 'root',
password => 'rootpass';
$ rex bench
[2015-06-13 15:27:07] <local> INFO - Running task bench on <local>
Benchmark: timing 100 iterations of new_large, new_small, old_large, old_small...
new_large: 2 0.11 0.11 0.62 0.03 100 None @ 114.94/s (n=100)
new_small: 2 0.06 0.16 0.52 0.06 100 None @ 125.00/s (n=100)
old_large: 108 0.17 0.21 101.85 5.35 100 None @ 0.93/s (n=100)
old_small: 2 0.11 0.28 0 0 100 None @ 256.41/s (n=100)
(warning: too few iterations for a reliable count)
Rate old_large new_large new_small old_small
old_large 0.930/s -- -99% -99% -100%
@ferki
ferki / Rexfile
Created August 17, 2015 12:54
passing values between tasks
use Rex -base;
task 'a', sub {
my $output_from_another_task = run_task 'b';
say $output_from_another_task;
};
task 'b', sub {
return 'I can pass scalars at least';
};
@ferki
ferki / Rexfile
Created August 18, 2015 09:48
get servergroup from parameter
use Rex -base;
use Getopt::Long;
my $buildserver;
GetOptions( 'buildserver=s' => \$buildserver );
group buildserver => $buildserver;
task 'a',