Skip to content

Instantly share code, notes, and snippets.

import boto3
import collections
import datetime
ec = boto3.client('ec2')
def lambda_handler(event, context):
reservations = ec.describe_instances().get(
'Reservations', []
)
#!/bin/bash
set -e
COOKBOOKS="`ls path/to/cookbooks`"
for BOOK in $COOKBOOKS; do
git subtree split --prefix chef/cookbooks/$BOOK --branch CB_Branch_$BOOK
rm -rf chef/cookbooks/$BOOK
done
#!/bin/bash
# Git subtree is included in git 1.7+, this part is only if you have below v1.7.
#git clone https://github.com/apenwarr/git-subtree.git && cd git-subtree
#sudo yum install xmlto asciidoc
#make doc
#sudo make install
cd ~/code/myrepo
git subtree split --prefix path/you/want --branch WhatIWant
#!/bin/sh
#
# Install NPM in the current virtualenv.
#
# Based on a post by Natim:
# http://stackoverflow.com/questions/8986709/how-to-install-lessc-and-nodejs-in-a-python-virtualenv
set -e
NODEJS="http://nodejs.org/dist/v0.11.6/node-v0.11.6-linux-x64.tar.gz"
package main
import (
"crypto/sha256"
"encoding/hex"
"fmt"
)
func main() {
hash := sha256.New()
caption string "%?%F%{= Bk}%? %C%A %D %d-%m-%Y %{= kB} %t%= %?%F%{= Bk}%:%{= wk}%? %n "
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]'
@ryansb
ryansb / cjd.instructions
Created April 19, 2013 18:29
Quick instructions for installing CJDNS on RHEL derivatives
yum install gcc gcc-g++ make git
cd /opt
git clone git://github.com/cjdelisle/cjdns.git
cd cjdns
./do
./cjdroute --genconf > /etc/cjdroute.conf
curl https://gist.github.com/ryansb/5422219/raw/4f8c788ce6d608e6e9539238ec8b39b6e13e4de2/cjdns > /etc/init.d/cjdns
@ryansb
ryansb / git_info.sh
Created April 16, 2013 17:10
Generates JSON blob for each commit in the master branch containing the author's name and the files they edited in that commit. I feel slightly bad for generating JSON with `echo` and `sed`.
#!/bin/bash
set -e
echo $(echo -n [
for csha in $(git rev-list master)
do
echo -n "
{\"author\": \"`git log --pretty=format:'%an <%ae>' -n1 $csha`\",
\"files\": [`for i in $(git ls-tree --name-only -r $csha); do echo -n \\\"$i\\\", ; done`]
},"
import json
from collections import defaultdict
gitinfo = json.loads(raw_input())
files_by_user = defaultdict(set)
users_by_file = defaultdict(set)
for commit in gitinfo:
for f in commit['files']:
@ryansb
ryansb / fossbox_backup.sh
Created April 9, 2013 22:45
Back up all git repos owned by all the users in the FOSSBox Github organization.
#!/bin/bash
set -e
cd backups
USERS=`python -c "import requests
for u in requests.get('https://api.github.com/orgs/FOSSRIT/public_members').json():
print u['login']"`
for user in $USERS