Skip to content

Instantly share code, notes, and snippets.

View andresdouglas's full-sized avatar

Andres Douglas andresdouglas

View GitHub Profile
@bohde
bohde / api.py
Created December 24, 2010 15:48
def post_list(self, request, **kwargs):
deserialized = self.deserialize(request,
request.raw_post_data,
format=request.META.get('CONTENT_TYPE',
'application/json'))
bundle = self.build_bundle(data=dict_strip_unicode_keys(deserialized))
self.is_valid(bundle, request)
updated_bundle = self.obj_create(bundle, request=request)
resp = self.create_response(request,
self.full_dehydrate(updated_bundle.obj))
@zyegfryed
zyegfryed / gist:814432
Created February 7, 2011 14:25
Tastypie OAuth
from oauth2 import Error
from django.utils.translation import ugettext as _
from tastypie.authentication import Authentication
from oauth_provider.utils import initialize_server_request, send_oauth_error, get_oauth_request
from oauth_provider.consts import OAUTH_PARAMETERS_NAMES
from oauth_provider.store import store, InvalidTokenError
@mlbright
mlbright / distkeys.py
Created February 23, 2011 16:25
deploy/distribute ssh public key to multiple hosts using Fabric
"""
usage:
fab -f distkeys.py set_hosts:/path/to/hosts_file add_key:/path/to/key
Use --password and --user options as necessary
Inspired by shell script at http://github.com/mlbright/mybin/raw/master/distkeys.sh
Fabric recipe to distribute your ssh key to large number of hosts.
@demonbane
demonbane / makeapp.sh
Created July 5, 2011 20:05
Create a Fluid-style app launcher for single-window Chrome instances on OSX
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name="$inputline"
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url="$inputline"
@pydanny
pydanny / field.html
Created November 8, 2011 16:33
django-uni-form + Twitter Bootstrap
<!-- this usually goes in <project-root>/templates/uni_form/field.html -->
{% if field.is_hidden %}
{{ field }}
{% else %}
<div class="clearfix {% if field.errors %}error{% endif %}">
<label for="{{ field.auto_id }}" {% if field.field.required %}class="requiredField"{% endif %}>
{{ field.label|safe }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
<div class="input">
@mattray
mattray / *shell*
Created December 23, 2011 16:59
shell commands for chef-server cookbook
knife cookbook upload apt
knife cookbook upload yum
knife cookbook upload build-essential
knife cookbook upload ucspi-tcp
knife cookbook upload erlang
knife cookbook upload runit
knife cookbook upload bluepill
knife cookbook upload daemontools
knife cookbook upload couchdb
knife cookbook upload apache2
@harlanbarnes
harlanbarnes / Vagrantfile
Created January 17, 2012 23:34
Vagrantfile Multi VM
user = ENV['OPSCODE_USER'] || ENV['USER']
base_box = ENV['VAGRANT_BOX'] || 'centos-5.5-x86_64'
Vagrant::Config.run do |config|
config.vm.define :web do |web_config|
web_config.vm.box = base_box
web_config.vm.forward_port("http", 80, 8080)
web_config.vm.provision :chef_client do |chef|
@fatbox
fatbox / djangomodule.py
Created January 28, 2012 14:22
Load Django modules from within a Salt module
"""
This allows you to import Django modules into a Salt module
"""
import logging
import sys
import os
log = logging.getLogger(__name__)
include:
- apt
# our custom sources
/etc/apt/sources.list.d/fatbox.list:
file:
- managed
- source: salt://fatbox/debian/apt/fatbox.list
- owner: root
- group: root
{% macro postconf(key, value) -%}
postconf-{{ key }}:
cmd:
- run
- name:
- postconf -e {{ key }}='{{ value }}'
- unless: test "x$(postconf -h {{ key }} )" = 'x{{ value }}'
- require:
- pkg: postfix