Skip to content

Instantly share code, notes, and snippets.

View thomasbilk's full-sized avatar
💭
Git is for gits

Thomas Bilk thomasbilk

💭
Git is for gits
View GitHub Profile
@thomasbilk
thomasbilk / vault_decrypt
Last active June 8, 2017 15:53 — forked from leucos/clean_vault
Ansible vault transparent encryption revisited
#!/bin/sh
tmp=`mktemp`
cat "${1--}" > $tmp
ansible-vault decrypt $tmp > /dev/null 2>&1
if [ $? -eq 0 ]; then
cat "$tmp"
else
cat "${1--}"
@thomasbilk
thomasbilk / mandelbrot.sql
Last active August 29, 2015 14:25 — forked from rupey/mandelbrot.sql
Mandelbrot plot in postgres
WITH RECURSIVE
x(i) AS ( VALUES (0)
UNION ALL SELECT i + 1
FROM x
WHERE i < 101),
Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
SELECT
Ix,
Iy,
X :: FLOAT,
@thomasbilk
thomasbilk / howto.md
Last active June 29, 2017 09:35
How to build a jruby jar with sass libs

Download jruby complete:

curl -O http://jruby.org.s3.amazonaws.com/downloads/1.7.13/jruby-complete-1.7.13.jar

Now rename it:

mv jruby-complete-1.7.13.jar scss.jar

Next install gems:

@thomasbilk
thomasbilk / fossil_rss.sh
Created July 31, 2014 18:39
Bash Script for generating RSS files for all Fossil repositories in a folder
#!/usr/bin/env bash
for fos in `ls /var/repos/*.fossil`; do
rss=`echo $fos | sed 's/\/var\/repos\/\(.*\)\.fossil/\1/'`;
/usr/local/bin/fossil rss -R $fos --url https://repos.com/$rss > /var/public/rss/$rss.rss;
done
@thomasbilk
thomasbilk / postgres.sql
Last active December 8, 2018 02:33
Solve Sudoku in SQL
WITH RECURSIVE x( s, ind ) AS
( SELECT sud, position( '.' IN sud )
FROM (SELECT '91.7......326.9.8...7.8.9...86.3.17.3.......6.51.2.84...9.5.3...2.3.149......2.61'::text
AS sud) xx
UNION ALL
SELECT substr( s, 1, ind - 1 ) || z || substr( s, ind + 1 )
, position('.' IN repeat('x',ind) || substr( s, ind + 1 ) )
FROM x
, (SELECT gs::text AS z FROM generate_series(1,9) gs) z
WHERE ind > 0
@thomasbilk
thomasbilk / firefox.conf
Created September 25, 2013 07:53
Sinnvolle Firefox Einstellungen
browser.fixup.alternate.enabled;false
browser.urlbar.trimURLs;false
general.smoothScroll;false
plugins.click_to_play;true
plugins.notifyMissingFlash;false
@thomasbilk
thomasbilk / .bashrc
Created August 17, 2013 19:06
bookmarks terminal shortcut to directories
export MARKPATH=$HOME/.marks
function jump {
cd -P $MARKPATH/$1 2>/dev/null || echo "No such mark: $1"
}
function mark {
mkdir -p $MARKPATH; ln -s $(pwd) $MARKPATH/$1
}
function unmark {
rm -i $MARKPATH/$1
}
@thomasbilk
thomasbilk / slugify.sql
Last active June 10, 2018 00:33
Pseudo Transliteration for Postgres aka `slugify`
CREATE OR REPLACE FUNCTION slugify(str text) RETURNS text AS $$
BEGIN
RETURN lower(translate(str,
'äëïöüáéíóúâêîûôåãõàèìòùřšěčůńýśćłęąĄŃÝŚĆŁĘÄËÏÖÜÁÉÍÓÚÂÊÎÛÔÅÃÕÀÈÌÒÙŘŠĚČŮß :;-²ø®(),./\"’`''',
'aeiouaeiouaeiouaaoaeioursecunyscleaANYSCLEAEIOUAEIOUAEIOUAAOAEIOURSECUs____2dR' -- missing chars will be removed
));
END
$$ LANGUAGE plpgsql;
@thomasbilk
thomasbilk / table_sizes.sql
Last active October 6, 2015 13:48
Size of all Tables in a Database
-- PostgreSQL
SELECT
schemaname,
tablename,
pg_size_pretty(size) AS size_pretty,
pg_size_pretty(total_size) AS total_size_pretty
FROM (
SELECT *,
pg_relation_size(schemaname||'.'||tablename) AS size,
@thomasbilk
thomasbilk / .bashrc
Created March 16, 2012 13:13
.bashrc file
# ~/.bashrc
export EDITOR=vim
export HISTCONTROL=ignoredups
export LSCOLORS=excxbxbxfxexexfxfxexex
alias ls="ls --color=auto"
alias ll="ls -lhF"
alias rm="rm -v"
alias pacman="pacman-color"