Skip to content

Instantly share code, notes, and snippets.

View iconara's full-sized avatar
🤖

Theo iconara

🤖
View GitHub Profile
@iconara
iconara / fujicolor.rb
Created June 29, 2016 13:23
Automatically tag Fujifilm raw files with the correct film simulation
#!/usr/bin/ruby
require 'shellwords'
require 'thread'
paths = Queue.new
ARGV.each { |path| paths << path }
# http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/FujiFilm.html
@iconara
iconara / deshake.rb
Created June 29, 2016 13:17
Timelapse deshaker
#!/usr/bin/env ruby
# brew install imagemagick
# brew install Caskroom/cask/hugin
require 'fileutils'
require 'thread'
require 'optparse'
ALIGN_COMMAND_PATH = '/usr/local/Caskroom/hugin/2014.0.0/HuginTools/align_image_stack'
@iconara
iconara / pingpong.rb
Last active May 10, 2016 05:53
Ione Ping Pong
# encoding: utf-8
$: << File.expand_path('../../lib', __FILE__)
require 'ione'
require 'thread'
MESSAGE = 'hello world!'
def setup_server(acceptor)
@iconara
iconara / queries.sql
Last active November 13, 2023 22:26
Low level Redshift cheat sheet
-- Table information like sortkeys, unsorted percentage
-- see http://docs.aws.amazon.com/redshift/latest/dg/r_SVV_TABLE_INFO.html
SELECT * FROM svv_table_info;
-- Table sizes in GB
SELECT t.name, COUNT(tbl) / 1000.0 AS gb
FROM (
SELECT DISTINCT datname, id, name
FROM stv_tbl_perm
JOIN pg_database ON pg_database.oid = db_id
@iconara
iconara / error-and-split.sh
Last active October 5, 2015 12:46
Find the error and file that caused an EMR job to shut down
#!/bin/bash
# Tested with EMR AMI 3.9.0, but most likely does not work except
# in fortuitous constellations of errors
failed_task_id=$(zgrep -F 'Task failed' steps/*/syslog.* | head -n 1 | perl -p -e 's/^.*(task_\S+).*$/$1/')
failed_task_log=$(zgrep -l -R -F $failed_task_id task-attempts | tail -n 1)
failed_attempt_id=$(zgrep -F FATAL $failed_task_log | head -n 1 | perl -p -e 's/^.*(attempt_\S+).*$/$1/')
failed_attempt_log=$(zgrep -l -R -F $failed_attempt_id task-attempts | tail -n 1)
@iconara
iconara / disable-awdl-and-airdrop.sh
Created September 18, 2015 17:14
Disable AWDL and AirDrop and hopefully fix the MBP WiFi issue
sudo ifconfig awdl0 down
@iconara
iconara / read-sequence-file-sans-humboldt.rb
Last active October 19, 2015 08:08
Read a sequence file
def read_sequence_file(path, key_type, value_type)
uri = "file://#{File.expand_path(path)}"
conf = Hadoop::Conf::Configuration.new
fs = Hadoop::Fs::FileSystem.get(java.net.URI.create(uri), conf)
path = Hadoop::Fs::Path.new(uri)
reader = Hadoop::Io::SequenceFile::Reader.new(fs, path, conf)
key = Hadoop::Util::ReflectionUtils.new_instance(reader.key_class, conf)
value = Hadoop::Util::ReflectionUtils.new_instance(reader.value_class, conf)
while reader.next(key, value)
yield key, value
@iconara
iconara / download.sh
Last active September 29, 2020 07:48
Download a CloudWatch Logs group
#!/bin/bash
log_group=$1
list_command="aws logs describe-log-streams --log-group-name $log_group"
group_next_token=''
while true; do
if [[ -n $group_next_token ]]; then
response=$($list_command --next-token $group_next_token)
else
@iconara
iconara / configuration
Created April 28, 2015 09:02
EdgeMAX QoS settings
set traffic-policy shaper DOWNLOAD-POLICY
set traffic-policy shaper DOWNLOAD-POLICY bandwidth 1000Mbit
set traffic-policy shaper DOWNLOAD-POLICY default bandwidth 100%
set traffic-policy shaper DOWNLOAD-POLICY default ceiling 100%
set traffic-policy shaper DOWNLOAD-POLICY default burst 15k
set traffic-policy shaper DOWNLOAD-POLICY default queue-type fair-queue
set traffic-policy shaper DOWNLOAD-POLICY class 2 bandwidth 20Mbit
set traffic-policy shaper DOWNLOAD-POLICY class 2 burst 15k
set traffic-policy shaper DOWNLOAD-POLICY class 2 ceiling 40Mbit
@iconara
iconara / jara.sh
Created February 10, 2015 17:09
Jara without Puck
#!/bin/bash
if [[ ! -d .git ]]; then
echo 'You must run this command from the root of the repository' 1>&2
exit 1
fi
environment=${1:-staging}
name=$(basename $PWD | tr - _)