Skip to content

Instantly share code, notes, and snippets.

@andersonvom
andersonvom / executive_orders.sh
Last active August 29, 2015 14:10
Gather number of executive orders by president, by year
#!/bin/bash
temp_dir=$(mktemp -d /tmp/orders.XXXX)
pushd $temp_dir
for year in $(seq 1994 2014) 2001-clinton 2001-wbush 2009-wbush 2009-obama
do
echo Downloading $year
wget -q "http://www.archives.gov/federal-register/executive-orders/$year.html"
done
@andersonvom
andersonvom / router.sh
Created October 11, 2014 19:31
Routing configuration to use the VPN for VPN stuff, and default gateway for everything else
#!/bin/bash
VPN_DEVICE=utun0
VPN_NETWORK=10
DEFAULT_GATEWAY=192.168.1.1 # home
host_exceptions=(
xxx.xxx.xxx.xxx # Some public service that needs to be accessed from the VPN
)
@andersonvom
andersonvom / eleicoes-2014.py
Last active April 11, 2016 02:37
Acompanhe os resultados das eleições para presidente de 2014 sem sair do terminal!
import logging
import os
import re
import requests
import subprocess
import time
loggers = {}
@andersonvom
andersonvom / openstack.rb
Last active August 29, 2015 14:07
Ruby script to start a new tmux session with the correct windows set up
#!/usr/bin/env ruby
HOME = Dir.home
OPENSTACK = File.join(HOME, 'development', 'openstack')
def openstack
session_name = 'openstack'
windows = {
screen: "cd #{OPENSTACK}; vagrant up && vagrant ssh",
vagrant: "cd #{OPENSTACK}; sleep 10 ; vagrant ssh",
@APP.task(base=ErrorHandler)
def calc_mrr():
mrr_chord = chord(
chain(get_resources.s(key), calc_revenue.s())
for key in mrr_stacks
)
return mrr_chord(mrr_total.s()) # mrr_total receives a list of AsyncResult
# but I need the actual results (the output of calc_revenue,
# which is the values returned by _sum_revenues)
@andersonvom
andersonvom / .gitconfig
Created September 11, 2014 22:27
Common GIT shortcuts - .gitconfig
[user]
name = Anderson Mesquita
email = find@out.com
[color]
ui = true
pager = true
[alias]
ci = commit
co = checkout
cp = cherry-pick
def no_none(props):
''' returns a dict with no None values'''
return {key: value
for key, value in props.iteritems()
if value is not None}
def handle_create(self):
properties = {
self.rs.nodes: self.nodes(),
@andersonvom
andersonvom / sample_random.sh
Created April 16, 2014 17:27
sample_random.sh
for i in 1 2 3 4 5 6 7 8 9 0;
do
echo $RANDOM
done
import mock
from heat.common import exception
from heat.common import template_format
from heat.engine import resource
from heat.engine import scheduler
from heat.tests import utils
from heat.tests.common import HeatTestCase
from ..resources import secret # noqa
@andersonvom
andersonvom / remove_extinct.js
Created March 24, 2014 16:16
Javascript to remove all extict distro lines from the linux SVG timeline.
var remove_extict = function() {
var line = null;
var dot = null;
var num_extinct = 0;
do {
try {
line = $('[marker-end]');
dot = $('#'+line.id.replace('__line', '__dot'));
line.remove();
// dot.remove()