Skip to content

Instantly share code, notes, and snippets.

Avatar

Johannes Berdin johannesberdin

View GitHub Profile
@johannesberdin
johannesberdin / lowercase.sql
Last active Aug 29, 2015
Generates ALTER TABLE queries for lowercased column names and table names
View lowercase.sql
/* Lowercases column names */
SELECT 'ALTER TABLE ' || quote_ident(c.table_schema) || '.' || quote_ident(c.table_name) || ' RENAME ' || quote_ident(c.column_name) || ' TO ' || quote_ident(lower(c.column_name)) || ';' As ddlsql FROM information_schema.columns As c WHERE c.table_schema NOT IN('information_schema', 'pg_catalog') AND c.column_name <> lower(c.column_name) ORDER BY c.table_schema, c.table_name, c.column_name;
/* Lowercases table names */
SELECT 'ALTER TABLE ' || quote_ident(c.table_schema) || '.' || quote_ident(c.table_name) || ' RENAME TO ' || quote_ident(lower(c.table_name)) || ';' As ddlsql FROM information_schema.tables As c WHERE c.table_schema NOT IN('information_schema', 'pg_catalog') AND c.table_name <> lower(c.table_name) ORDER BY c.table_schema, c.table_name;
@johannesberdin
johannesberdin / convert.sh
Last active Apr 20, 2020
Script for recursively converting all files to UTF-8 (Mac OS X)
View convert.sh
#!/bin/bash
# Original by LEXO, http://www.lexo.ch
# Link: https://www.lexo.ch/blog/2013/01/linux-bash-shell-script-for-recursively-converting-all-files-with-various-charsets-in-a-directory-into-utf-8-shell-skript-fur-das-rekursive-konvertieren-von-allen-files-in-einem-verzeichnis-mit-belie/
# Changed by Johannes Berdin, http://johannesberdin.de
# for running under Mac OS X
#
# Version 1.0
#
# This bash script converts all files from within a given directory from any charset to UTF-8 recursively
You can’t perform that action at this time.