Skip to content

Instantly share code, notes, and snippets.

@pstorch
pstorch / chsh_zsh_winbind
Created June 20, 2016 08:59
Change login shell to zsh when ldap login via winbind is used
echo template shell = /bin/zsh | sudo tee /etc/samba/smb.conf.local; sudo service winbind restart
@pstorch
pstorch / amazon-instance-packer.json
Last active January 27, 2017 18:24
Provision AWS Ubuntu AMI for packer.io with amazon-instance builder. If you have Problems with ec2-ami-tools: "ec2-bundle-vol command not found".
{
"variables": {
"aws_access_key": "",
"aws_secret_key": ""
},
"builders": [{
"type": "amazon-instance",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"account_id": "<<YOUR_ACCOUNT_ID>>",
@pstorch
pstorch / hg-pull-u.sh
Created September 25, 2015 07:42
Recursivly update all hg repos in a folder
#!/bin/bash
for f in *; do
if [ -d "$f" ]; then
hg pull -u -R "$f"
fi
done
@pstorch
pstorch / emr_bootstrap_java_8.sh
Last active September 18, 2017 04:07 — forked from ericeijkelenboom/emr_bootstrap_java_8.sh
Bootstrap script for installing Java 8 on an Amazon Elastic MapReduce instance (emr-4.0.0)
# Check java version
JAVA_VER=$(java -version 2>&1 | sed 's/java version "\(.*\)\.\(.*\)\..*"/\1\2/; 1q')
if [ "$JAVA_VER" -lt 18 ]
then
# Figure out how many versions of Java and javac we currently have
NR_OF_JRE_OPTIONS=$(echo 0 | alternatives --config java 2>/dev/null | grep 'There ' | awk '{print $3}' | tail -1)
NR_OF_SDK_OPTIONS=$(echo 0 | alternatives --config javac 2>/dev/null | grep 'There ' | awk '{print $3}' | tail -1)
# Silent install javac (includes jre)
@pstorch
pstorch / schema_size.sql
Created May 7, 2015 20:16
Select schemas and their used size in PostgreSQL
SELECT schema_name,
pg_size_pretty(sum(table_size)::bigint),
sum(table_size)::bigint,
(sum(table_size) / pg_database_size(current_database())) * 100
FROM (
SELECT pg_catalog.pg_namespace.nspname as schema_name,
pg_relation_size(pg_catalog.pg_class.oid) as table_size
FROM pg_catalog.pg_class
JOIN pg_catalog.pg_namespace ON relnamespace = pg_catalog.pg_namespace.oid
) t