Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
#
# Modified TMUX start script from:
# http://forums.gentoo.org/viewtopic-t-836006-start-0.html
#
# Store it to `~/bin/tmx` and issue `chmod +x`.
#
# Works because bash automatically trims by assigning to variables and by
@takus
takus / mr_counting_job.py
Last active August 29, 2015 14:04
mrjob's unit test example
from mrjob.job import MRJob
from mrjob.step import MRStep
class MRCountingJob(MRJob):
def __init__(self, *args, **kwargs):
super(MRCountingJob, self).__init__(*args, **kwargs)
def steps(self):
# 3 steps so we can check behavior of counters for multiple steps
@takus
takus / fluentd.py
Last active August 29, 2015 14:05
Fluentd check for Datadog (https://app.datadoghq.com)
# stdlib
import re
import urllib2
import urlparse
# project
from util import headers
from checks import AgentCheck
from checks.utils import add_basic_auth
@takus
takus / emr.sh
Last active August 29, 2015 14:05
#!/bin/sh
JOB_FLOW_ID=`mrjob create-job-flow`
for n in `seq 1 ${LOOP_NUMBER}`
do
python ${MRJOB_SCRIPT} -r emr --conf-path emr.conf --emr-job-flow-id=${JOB_FLOW_ID} ${MRJOB_OPTION} ${INPUT_DIR} > ${OUTPUT_FILE}
done
mrjob terminate-job-flow ${JOB_FLOW_ID}
@takus
takus / mysql.yml
Last active August 29, 2015 14:16
embulk error
in:
type: mysql
user: xxxx
password: xxxx
database: xxxx
host: xxxx
select: "*"
table: "test"
out:
@takus
takus / c_trace.txt
Last active August 29, 2015 14:20
fluent-plugin-dd
#0 0x00007f703ffeb956 in ppoll () from /lib64/libc.so.6
#1 0x00000000004f7d53 in rb_wait_for_single_fd (fd=<optimized out>, events=1, tv=<optimized out>) at thread.c:2862
#2 0x0000000000428a41 in rb_io_wait_readable (f=19) at io.c:907
#3 0x00007f70355be307 in ossl_start_ssl (self=140119728098360, func=0x7f70353891e0 <SSL_connect>, funcname=0x7f70355df60b "SSL_connect", nonblock=0)
at ossl_ssl.c:1146
#4 0x00000000004e4edf in vm_call_cfunc (me=<optimized out>, blockptr=<optimized out>, recv=<optimized out>, num=<optimized out>, reg_cfp=<optimized out>,
th=<optimized out>) at vm_insnhelper.c:404
#5 vm_call_method (th=0x7f702ed6d400, cfp=0x7f702d605818, num=0, blockptr=0x1, flag=0, id=20640, me=0x7f7035c11ae0, recv=140119728098360) at vm_insnhelper.c:530
#6 0x00000000004e7ad0 in vm_exec_core (th=0x7f702ed6d400, initial=<optimized out>) at insns.def:1018
#7 0x00000000004ec706 in vm_exec (th=0x7f702ed6d400) at vm.c:1236
@takus
takus / riaudit.rb
Last active September 17, 2015 05:21 — forked from cognusion/riaudit.rb
Simple script to audit AWS EC2 Reserved Instances vs Instances running.
#!/usr/bin/env ruby
# Audits your reserved instances vs your running instances, and reports back.
# If you want to run this from an AWS instance, its IAM Role must be granted at least the following:
#
#{
# "Statement": [
# {
# "Action": [
# "ec2:DescribeInstances",
@takus
takus / IPC-Cmd-Sample.pl
Created October 8, 2011 23:47
Execute external openssl command by using IPC::Cmd
use IPC::Cmd qw/can_run run/;
our $OPENSSL = can_run('openssl') or die 'openssl is not installed!';
my $ok = run(
verbose => 0,
command => [
"openssl", "enc",
"-e", "-aes256",
"-in", $input,
@takus
takus / find-all-files-in-directory.pl
Created October 9, 2011 09:32
Find all files in a directory
opendir DH, $dir or die "Error: can't open $dir : $!";
while (my $file = readdir DH) {
next if $file =~ /^\.{1,2}$/;
print $file, "\n";
}
closedir DH;
@takus
takus / copy_to_temp_file.pl
Created October 9, 2011 14:37
Create temp file from existing file
#!/usr/bin/env perl
use strict;
use warnings;
use File::Temp;
use File::Copy;
my $origin_file = shift;