Skip to content

Instantly share code, notes, and snippets.

@ryansb
ryansb / flash_drive_autocopy.sh
Created September 3, 2012 20:10
Copy SJ's magic to flash drives
find /run/media/ryansb -maxdepth 1 -type d | sed 1d |while read line
do
echo "$line"
rm -r $line/*
cp -r /home/ryansb/IGIC/*.pdf $line
chmod 777 $line/*
umount $line
done
echo "Done!"
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from os import mkdir
from os import getcwd
from os.path import exists
DATA = open('/home/ryansb/random_corpus').read()
COUNTER = 0
@ryansb
ryansb / doordecs.py
Created March 10, 2013 16:34
Just put an image at ./dec.jpg (or any other image you like) and input your names and you're all set to print as many door decs as you need. Work saved.
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
font = ImageFont.truetype("/usr/share/fonts/dejavu/DejaVuSans.ttf", 75)
namelist = [
# names go here
]
def fpo(opt):
def fakereturn(noop):
return opt.pop(0)
return fakereturn
mock (pythong.project.prompt_optionlist = fpo(["Development Status", None, "Operating Systems", "Linux", "Fedora"]))
from pythong.classifiers import CLASSIFIERS
assert(recurse_prompt(CLASSIFIERS) == "Operating Systems :: Linux :: Fedora")
sudo yum install -y gcc curl-devel
sudo yum localinstall -y http://pkgs.repoforge.org/htop/htop-1.0.2-1.el6.rf.x86_64.rpm
wget https://www.schneier.com/code/skein.zip
unzip skein.zip
cd NIST/CD/Optimized_64bit
import json
import urllib2
import pygal
# construct our API URL with type parameter set to 'alltimesum'
apiurl = 'http://mcsafetyfeed.org/api/counts.php?type=alltimesum'
# retrieve the JSON object via the API URL
data = json.load( urllib2.urlopen( apiurl ) )
@ryansb
ryansb / github_backup.sh
Last active December 16, 2015 00:39
Take a username and back up all of their git repos. Works for organizations as well.
#!/bin/bash
set -e
if [ -z $2 ]
then
TYPE=users
else
TYPE=orgs
fi
@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
@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']: