Skip to content

Instantly share code, notes, and snippets.

@xdbr
xdbr / a.rb
Created August 27, 2015 10:34
execution order?
find $(pwd ; echo $(ls)) -name $(echo "*.bar") -maxdepth 1
@xdbr
xdbr / a.rb
Last active August 29, 2015 14:27
osx: join network from commandline // network should not include spaces // needs "fzf" and "pass" installed
network=$(airport -s | fzf | cut -b 1-33 | sed -e 's/^ *//' -e 's/ *$//') && networksetup -setairportnetwork en0 $network $(pass wifi/$network)
@xdbr
xdbr / a.rb
Created August 19, 2015 18:38
JAPH
perl -E '%~=@~=(-japh,japh,j,just,a,another,p,perl,h,hacker),( $_ = @~[ ~-@~ ] )~~( y-hacker-japh-s,s - *(~|j|~|a|~|p|~|h|~) *- ~~ "$~{$+} " -goppie,-say,)'
@xdbr
xdbr / a.rb
Created August 19, 2015 18:39
find stale, leftover branches in git (add to ~/.gitconfig)
stale = "! abandoned_branches() { \
for branch in `git branch -r --no-merged | grep -v HEAD`; do \
echo `git show --format='%ci %cr %ae' $branch | head -n 1` $branch; \
done | sort -r | column -t; \
}; abandoned_branches"
@xdbr
xdbr / foo.perl
Created August 19, 2015 19:03
Build GNU make dependency graph using dot
#!/usr/bin/env perl
use strict;
use warnings;
use feature 'say';
@ARGV or die "Usage:\n\tperl $0 Makefile\nthen:\n\t | dot -Tpng -oout.png\n";
my $dotopts = q{
# rankdir=LR
# node [shape=record,width=.1,height=.1]
@xdbr
xdbr / a.rb
Created September 5, 2015 13:15
coins
perl -E '$:+=+shift;do{$:-=$_,$@++while$:-$_>=0;say"$@x",$_>=1?"$_€":($_*100,"¢"),if$@;$@=0}for+2,1,.5,.2,.1,.05,.01' 15.43
@xdbr
xdbr / gist:64dda273e7490d142acc
Created September 6, 2015 15:28
how many coins to i need?
perl -E'!+0,$ ,=$",$:+=+shift,=>map{$:-=$_=>push@,=>$_>=!$!?~~qq,$_€,:($_*100.).q.¢.while$:-$_>=$!}2,1,.5,.2,.1,.05,.01;say+0||@,' 1.23
@xdbr
xdbr / holiday.sh
Created October 6, 2015 14:10
Redmine holiday-API
URL=https://redmine.your-company.com APIKEY=YOURPERSONALAPIKEY MESSAGE="Holiday" HOURS=8.0 ISSUE_ID=issue_id_here LC_ALL=C; \
for weekday in 2015-09-{21..30} 2015-10-{01..04}; do
case $((date -jf '%F' $weekday || date -d $weekday) 2>/dev/null | awk '{print $1}') in
(Mon|Tue|Wed|Thu|Fri) \
printf "Entering $weekday... " && \
echo '<time_entry>
<issue_id>${ISSUE_ID}</issue_id>
<hours>${HOURS}</hours>
<comments>${MESSAGE}</comments>
<spent_on>'${weekday}'</spent_on>
@xdbr
xdbr / gist:72dc565aa59dbf403566
Last active October 15, 2015 10:37
markdown to html for wordpress
cat <(echo '<style>code {display: inline;padding: 2px;border: none;}</style>') input.html | perl -MHTML::Entities -pe 's{<pre><code>}{<pre>}g; s{</code></pre>}{</pre>}g; decode_entities $_'
# ~/.tmuxinator/fpm.yml
name: fpm
root: ~/code/agenten/fpm
# Optional tmux socket
# socket_name: foo
# Runs before everything. Use it to start daemons etc.
# pre: sudo /etc/rc.d/mysqld start