Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am adriancb on github.
  • I am adriancb (https://keybase.io/adriancb) on keybase.
  • I have a public key ASAkQk6CBZPmdoM0GOpGNzmYsIFhIJ4veX8KX7a3z6vHigo

To claim this, I am signing this object:

@adriancb
adriancb / download_ftp_tree.py
Created May 8, 2019 06:33 — forked from Jwely/download_ftp_tree.py
recursive ftp directory downloader with python
import ftplib
import os
import re
"""
MIT license: 2017 - Jwely
Example usage:
``` python
import ftplib
@adriancb
adriancb / size.rb
Created June 18, 2015 18:16
Show size of PG tables
ActiveRecord::Base.connection.execute("SELECT relname AS relation, pg_size_pretty(pg_relation_size(C.oid)) AS size FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') ORDER BY pg_relation_size(C.oid) DESC LIMIT 100;").each {|c| puts c}
@adriancb
adriancb / postgres_journaling.sh
Last active October 26, 2018 19:11
Create separate partition for Postgres
# create a separate partition and initialize with ext4
sudo mkfs.ext4 /dev/xvdb
# turn off journaling
sudo tune2fs -o journal_data_writeback /dev/xvdb
sudo tune2fs -O ^has_journal /dev/xvdb
# add to fstab
echo '/dev/xvdb /mnt/databases ext4 defaults,auto,noatime,nodiratime,noexec 0 0' | sudo tee -a /etc/fstab
@adriancb
adriancb / convert.sh
Created January 13, 2015 15:19
FLAC to MP3
#!/bin/bash
for f in "$@"; do
[[ "$f" != *.flac ]] && continue
album="$(metaflac --show-tag=album "$f" | sed 's/[^=]*=//')"
artist="$(metaflac --show-tag=artist "$f" | sed 's/[^=]*=//')"
date="$(metaflac --show-tag=date "$f" | sed 's/[^=]*=//')"
title="$(metaflac --show-tag=title "$f" | sed 's/[^=]*=//')"
year="$(metaflac --show-tag=date "$f" | sed 's/[^=]*=//')"
genre="$(metaflac --show-tag=genre "$f" | sed 's/[^=]*=//')"
@adriancb
adriancb / burning_man
Created August 11, 2014 21:58
burning_man
- Vinegar for Playa Dust
- Prepare for all types of weather, Rain is the worst
- Mallet
- Duct Tape
- Rebar for tents and shelters - pegs will not do it, winds are very strong - Home Depot
- Shade cloths
- 1.5 gallons of water per person per day
- Greywater (esky water), spray it around the camp to keep the dust down
- Electrolytes
- Spray bottles for bathing
@adriancb
adriancb / remove_all_gems.sh
Created May 12, 2014 18:35
Remove all gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
ffmpeg -i input.avi -acodec libfaac -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 output.mp4
ffmpeg -i input.mkv -c:v copy -c:a copy output.mp4
@adriancb
adriancb / spec_helper_coverage.rb
Created August 9, 2013 18:10
Simplecov config.
unless ENV['DRB']
require 'simplecov'
SimpleCov.start 'rails' do
add_group "Views", "app/views"
add_filter '/spec/'
add_filter '/config/'
add_filter '/lib/'
add_filter '/vendor/'
end
@adriancb
adriancb / purge_logs
Created August 8, 2013 17:57
Drop the memory usage of .bin files in the MySQL data directory
PURGE BINARY LOGS BEFORE DATE_SUB( NOW( ), INTERVAL 7 DAY);