This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO $$ DECLARE | |
r RECORD; | |
BEGIN | |
FOR r IN | |
SELECT tablename FROM pg_catalog.pg_tables WHERE schemaname = 'public' | |
LOOP | |
EXECUTE 'DROP TABLE ' || quote_ident(r.tablename) || ' CASCADE'; | |
END LOOP; | |
END $$; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
in="$1" | |
out="$(echo "$in" | sed 's/\.c$//g')" | |
rand="$(date +%s)$(LC_ALL=C tr -dc a-zA-Z0-9 < /dev/urandom | head -c10)" | |
cleanup() { | |
rm -rf "$rand$out" | |
} | |
trap cleanup EXIT | |
if ! clang -Wall -Wextra "$in" -o "$rand$out"; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"flag" | |
"fmt" | |
"io" | |
"io/ioutil" | |
"log" | |
"os" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
shopt -s extglob | |
HELP=" Usage: multiprocessor.sh --pythonscript <script.py> --datadir <data_directory> [--resultdir <result_directory> --removeheaders --jobs <num_of_jobs>] | |
multiprocessor.sh coordinates multiple instances of the same python script to | |
run concurrently on files inside the data directory. This allows you to write | |
python scripts that are single-threaded in nature, and let this script handle | |
the concurrency. | |
The only requirement is that the python script print its result to standard |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get update | |
sudo apt-get install -y mysql-server | |
# sudo mysql_secure_installation | |
echo " | |
CREATE USER 'pg'@'localhost' IDENTIFIED BY 'pg'; | |
CREATE USER 'pg'@'%' IDENTIFIED BY 'pg'; | |
GRANT ALL PRIVILEGES ON *.* TO 'pg'@'localhost' WITH GRANT OPTION; | |
GRANT ALL PRIVILEGES ON *.* TO 'pg'@'%' WITH GRANT OPTION; | |
FLUSH PRIVILEGES; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "bind R source-file ~/.tmux.conf\\; display \"Reloaded!\" | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
bind e last-window | |
bind-key @ break-pane \\; last-window | |
bind-key S choose-window 'join-pane -v -s \"%%\"' | |
bind-key V choose-window 'join-pane -h -s \"%%\"' | |
set -sg escape-time 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1) Install virtualbox https://www.virtualbox.org/wiki/Downloads | |
# 2) Download the latest ubuntu ISO https://ubuntu.com/download/desktop | |
# 3) Setup a new Virtualbox VM with the Ubuntu ISO (2GB RAM & 8GB Disk, dynamically allocated. Adjust to taste) | |
# 4) Install Virtualbox guest additions for the Ubuntu VM | |
# Open a terminal, run this script | |
# Add PostgreSQL APT repository https://www.postgresql.org/download/linux/ubuntu/ | |
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://stackoverflow.com/questions/3318727/postgresql-index-usage-analysis | |
SELECT relname, seq_scan-idx_scan AS too_much_seq, | |
case when seq_scan-idx_scan>0 THEN 'Missing Index?' ELSE 'OK' END, | |
pg_relation_size(relid::regclass) AS rel_size, seq_scan, idx_scan | |
FROM pg_stat_all_tables | |
WHERE schemaname='public' AND pg_relation_size(relid::regclass)>80000 | |
ORDER BY too_much_seq DESC; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
spawn dlv debug | |
expect "(dlv) " | |
foreach bp [lrange $argv 0 end] { | |
send "break $bp\r" | |
} | |
send "continue\r" | |
interact |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dump_tar_xz_contents() { | |
total="$1" | |
index="$2" | |
file="$3" | |
file_without_extension="$(basename "$file" .tar.xz)" | |
echo "[START][$index/$total] $file" | |
tar tf "$file" > "$file_without_extension.txt" | |
echo "[END][$index/$total] $file" |