Skip to content

Instantly share code, notes, and snippets.

View tovbinm's full-sized avatar
⌨️
<typing sounds>

Matthew Tovbin tovbinm

⌨️
<typing sounds>
View GitHub Profile
@tovbinm
tovbinm / hack.sh
Created April 9, 2012 19:18 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
1. Open terminal inside your virtual machine and run:
sudo dd if=/dev/zero of=EMPTY bs=1M
sudo rm ./EMPTY
This will zeroify all the empty blocks on your disk.
2. Shutdown you virtual box.
3. Check what type of virtual drive do you have: VMDK or VDI. VirtualBox shrinking works only with VDI files.
If you have a VDI file, proceed to the last step, otherwise you'll need to perform an additional step of converting your VMDK file
#!/bin/bash
apt-get -y update
apt-get -y install mdadm
echo "y" | mdadm --create /dev/md0 --level 0 --raid-devices 2 /dev/xvdb /dev/xvdc
echo "DEVICE /dev/xvdb /dev/xvdc" > /etc/mdadm/mdadm.conf
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
blockdev --setra 65536 /dev/md0
mkfs.ext3 -F /dev/md0
mkdir -p /mnt/dataraid && mount -t ext3 /dev/md0 /mnt/dataraid -o noatime
echo "/dev/md0 /mnt/dataraid ext3 noatime 0 0" | tee -a /etc/fstab
ADD JAR s3://<s3-bucket>/jars/hive_contrib-0.5.jar;
CREATE TEMPORARY FUNCTION now as 'com.mt.utils.udf.Now';
CREATE TEMPORARY FUNCTION user_agent_f as 'com.mt.utils.UserAgent';
set hive.merge.mapredfiles=true;
set hive.merge.mapfiles=true;
set hive.merge.size.per.task=500000000;
CREATE EXTERNAL TABLE data
var c = require('riak-js').getClient({ host: 'hostname', port: 8098 });
var mr = c.add('bucket').map(function m(v){return [1]}).reduce(function(v) { return [v.reduce(function(t, val) { return t + val; }, 0)]});
mr.run({timeout: 10000000});
@tovbinm
tovbinm / gist:1935634
Created February 28, 2012 22:18
Get ec2 instance FQDN
ec2hm=`curl -s http://169.254.169.254/latest/meta-data/public-ipv4`; echo ec2-${ec2hm//./-}.compute-1.amazonaws.com; unset ec2hm
@tovbinm
tovbinm / gist:1904702
Created February 24, 2012 23:54
Making use of PageDown/PageUp/Home/End keys in Max OS X terminal
1. Open Mac OS x terminal
2. Go to Preferences -> Settings -> Keyboard
3. Redefine keys to "Send string to shell" as follows:
Key Escape Sequence
Home \033[1~
End \033[4~
Page Up \033[5~
Page Down \033[6~
@tovbinm
tovbinm / bashrc
Created February 23, 2012 01:58
Git/SVN branch in bash
parse_git_branch () {
git symbolic-ref HEAD 2> /dev/null | sed 's#refs/heads/\(.*\)# \1#'
}
parse_svn_branch() {
parse_svn_url | sed -e 's#^'"$(parse_svn_repository_root)"'##g' |
awk '{print " (svn::"$1")" }'
}
parse_svn_url() {
svn info 2>/dev/null | sed -ne 's#^URL: ##p'
}
@tovbinm
tovbinm / crontab
Created February 22, 2012 01:10
Logrotate & upload nginx logfiles to s3://bucket/dt=..../hostname.log...gz
# Nginx - logrotate & upload to S3
0 0 * * * /usr/sbin/logrotate /etc/logrotate.d/nginx
15 0 * * * s3cmd put /var/log/nginx/access.log-`date +"\%Y\%m\%d"`.gz s3://$LOGS_BUCKET_NAME/nginx-access/`date +"dt=\%Y\%m\%d"`/`hostname -s`.access.log-`date +"\%Y\%m\%d"`.gz
$ diff -u riakclient.proto.piqi riakclient.proto.piqi.edited
--- riakclient.proto.piqi 2012-02-08 20:55:35.000000000 -0600
+++ riakclient.proto.piqi.edited 2012-02-08 20:55:25.000000000 -0600
@@ -299,6 +299,7 @@
]
.field [
.name done
+ .ocaml-name "ocaml_done"
.type bool
.optional