Skip to content

Instantly share code, notes, and snippets.

View rochacon's full-sized avatar

Rodrigo Chacon rochacon

  • Remote
  • 15:12 (UTC -03:00)
View GitHub Profile
@rochacon
rochacon / gist:1263923
Created October 5, 2011 08:21
Django LoginRequiredView, for easy protected class based views
"""
This is a simple class based view that require the user login to be displayed
It's is intented to be used as a base class for another class based views
Use it like this:
from django.views.generic import TemplateView
from mylib import LoginRequiredView
@rochacon
rochacon / gist:1514222
Created December 23, 2011 13:32
Easy Django ModelForm widget placeholder
#
# This code inserts the placeholder attribute, using the field's label,
# for all TextInput, Textarea, DateInput, DateTimeInput, TimeInput widgets
# of your ModelForm
#
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
def __init__(self, *args, **kwargs):
@rochacon
rochacon / concur.py
Created January 30, 2013 14:37
Simple script to test Python's concurrent.futures backport
#!/usr/bin/env python
# pip install futures
from concurrent import futures
import time
import random
def sleep(me, x):
@rochacon
rochacon / map.py
Last active December 20, 2015 09:48
# /usr/bin/time -f '%E - %P%% cpu - %M kbytes ram' python tmp/map.py ~/Desktop >tmp/map.json
import hashlib
import json
import os
import sys
def get_file_hash(path):
h = hashlib.sha256()
with open(path, 'rb') as fp:
@rochacon
rochacon / s3proxy.go
Last active September 28, 2018 12:20
S3 Proxy in Go
package main
import (
"crypto/sha256"
"flag"
"fmt"
"github.com/gorilla/mux"
"hash"
"io"
"launchpad.net/goamz/aws"
@rochacon
rochacon / hello-tsuru.log
Created November 5, 2013 05:25
Hello Tsuru problems
$ git push
Counting objects: 5, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 328 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Cloning into '/home/application/current'...
remote: /
remote: requirements.apt not found.
remote: Skipping...
@rochacon
rochacon / setup-update-hook.sh
Last active December 29, 2015 11:19
Simple setup of git repository update hook to run Chef solo
#!/bin/bash
if [[ $# -lt 2 ]]; then
echo "Usage: setup-git-push-deploy.sh hostname project"
exit 1;
fi
host="$1"
PROJECT="$2"
@rochacon
rochacon / Vagrantfile
Last active December 29, 2015 16:59
JuJu+Jenkins Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
$bootstrap = <<SCRIPT
apt-get update -yq
apt-get install -yq python-software-properties
add-apt-repository -y ppa:juju/stable
apt-get update -yq
apt-get install -yq juju-local
echo -e 'y\n' | ssh-keygen -q -t rsa -N '' -f ~/.ssh/id_rsa
@rochacon
rochacon / elastic-nginx-cli.go
Last active December 30, 2015 21:18
Simple Elastic-NGINX cli for testing
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
"net/http/httputil"
@rochacon
rochacon / bootstrap.sh
Last active January 2, 2016 16:09
Simple flynn/gitreceiver-next receiver script to build and run a slug
#!/bin/bash
# This script will setup your server from scratch
set -e
# Setup Docker
curl -sL http://get.docker.io/ | bash
docker pull flynn/slugbuilder
docker pull flynn/slugrunner