Skip to content

Instantly share code, notes, and snippets.

@weavenet
weavenet / gist:9787119
Created March 26, 2014 16:20
Find and replace strings across files recursively in a directory on OS X.
find . -type f -name '*.txt' -exec sed -i '' s/123/321/ {} +
@weavenet
weavenet / 1_working.hs
Last active August 29, 2015 14:00
Mixing pure and in-pure functions in Haskell
import Data.Char
data Request = Request { message :: String }
main = getIt
getIt :: IO()
getIt = do
msg <- getLine
let r = Request { message = msg }
@weavenet
weavenet / dotfiles.md
Last active August 29, 2015 14:12
Why I Made My Dotfiles Private

Private Dotfiles

I recently moved my dotfiles to a private location. This goes against my previous belief in sharing the knowledge and allowing other to read and learn from my configuration.

Below is why:

Privacy

@weavenet
weavenet / gist:1540224
Created December 30, 2011 15:02
Convert M4A files across multiple directories to MP3s using faad & lame
#!/bin/bash
find /tmp -name '* *' | while read filename; do
echo "Converting:$filename"
faad -o - "$filename" | lame - "${filename%.m4a}.mp3"
done
@weavenet
weavenet / gist:1543197
Created December 31, 2011 07:07
Configure Rails 3.1.X to use HAML, rspec andfactory girl
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.1.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@weavenet
weavenet / metadata -> ec2
Created January 6, 2012 15:51
Posting Metadata for Asynchronous EC2 Instance Bootstrapping Consumption
Start an instance and specify the metadata with -d.
# ec2-run-instances --region us-east-1 -key 'key' --instance-type 'm1.large' ami-1927f370 -d 'this is the data I need'
RESERVATION r-67bdc406 608324328795 default
INSTANCE i-5ad9aa38 ami-1927f370 pending weaver 0 m1.large 2012-01-06T15:44:47+0000 us-east-1b aki-08ed0761 monitoring-disabled ebs paravirtual xen sg-357c745c default
Retrieve the instance hostname.
# ec2-describe-instances --region us-east-1 i-5ad9aa38 | grep ^INSTANCE | awk {'print $4'}
@weavenet
weavenet / rc.local
Created January 6, 2012 20:58
Custom rc.local for RHEL5 to create ec2-user, enable full sudo and execute user-data on first boot
#!/bin/sh
#
# Modified by bweaver to add root key to ea user
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
@weavenet
weavenet / gist:1572391
Created January 6, 2012 21:03
Script to cleanup RHEL5 instance before creating AMI
#!/bin/bash
USER=ec2-user
echo 'Removing host keys'
sudo /bin/rm -rf /etc/ssh/ssh_host*_key*
echo 'Removing ec2-user'
userdel -f $USER ; /bin/rm -rf /home/$USER
@weavenet
weavenet / gist:1595238
Created January 11, 2012 15:42
Script To Remove Non Whitelists RPMs
#!/bin/bash
whitelist=ami_rpm_whitelist.txt
# List rpms to installed rpmts
rpm -q -a > /tmp/installed_rpms
# create white list file of rpms installed on the given whitelist
for i in `cat $whitelist |tr -d '\r'`; do
egrep ^$i /tmp/installed_rpms
@weavenet
weavenet / gist:1597127
Created January 11, 2012 22:20
Build Ruby 1.8.7p174 RPM on RHEL5u6 using FPM
#!/bin/bash
# Fucking umask!!!
umask 022
# Install epel yum repo
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# Install deps for ruby build
yum install -y gcc rpm-build readline-devel.x86_64 libffi-devel.x86_64 libyaml-devel.x86_64 zlib-devel.x86_64 openssl-devel.x86_64 wget