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 / gunicorn_lighttpd.conf
Created August 8, 2010 16:54
gunicorn lighttpd conf file
server.modules = (
"mod_access",
"mod_alias",
"mod_accesslog",
"mod_extforward",
"mod_rewrite",
#"mod_fastcgi",
"mod_proxy",
"mod_redirect" )
@thomasbilk
thomasbilk / .vimrc
Created January 3, 2012 13:51
vimrc file
set enc=utf-8
" set fencs=utf8
set ruler
set number
set autoindent
set expandtab
set incsearch
set shiftwidth=4
set tabstop=4
set showcmd
@thomasbilk
thomasbilk / database_size.sql
Last active December 31, 2021 22:09
Database Sizes
-- PostgreSql
SELECT
pg_database.datname AS "Database Name",
pg_database_size(pg_database.datname) / 1024.0 / 1024.0 AS "Database Size (MB)"
FROM pg_database;
-- MySql
SELECT
table_schema "Database Name",
sum( data_length + index_length ) / 1024 / 1024 "Database Size (MB)"
@thomasbilk
thomasbilk / infile.csv
Created March 7, 2012 14:01
PowerShell Script for Generating Active Directory User Accounts
firstname lastname email username
Bill Gates gates@microsoft.com bill.gates
Steve Ballmer ballmer@microsoft.com steve.ballmer
@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"
@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 / 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 / .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 / 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 / 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