This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
Vagrant::Config.run do |config| | |
config.vm.define :opencenter do |config| | |
config.vm.box = 'precise64' | |
config.vm.host_name = 'opencenter-server.vm' | |
config.vm.customize ['modifyvm', :id, '--memory', 1024] | |
config.vm.network :hostonly, '172.20.0.10' | |
config.vm.provision :shell, :inline => 'apt-get update; apt-get -y install curl htop vim' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.http import HttpResponse | |
from django.conf import settings | |
CORS_ALLOW_ORIGIN = getattr(settings, 'CORS_ALLOW_ORIGIN', '*') | |
CORS_ALLOW_METHODS = getattr(settings, 'CORS_ALLOW_METHODS', ['POST', 'GET', 'PUT', 'DELETE', 'OPTIONS']) | |
CORS_ALLOW_HEADERS = getattr(settings, 'CORS_ALLOW_HEADERS', ['content-type', 'authorization']) | |
CORS_ALLOW_CREDENTIALS = getattr(settings, 'CORS_ALLOW_CREDENTIALS', True) | |
class CorsMiddleware(object): | |
def _set_headers(self, response): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
var cacheBust = 0, | |
hashInterval, | |
lastHash; | |
this.xd = { | |
postMessage: function(message, targetOrigin, otherWindow) { | |
if (!targetOrigin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
var cacheBust = 0, | |
hashInterval, | |
lastHash; | |
this.xd = { | |
postMessage: function(message, targetOrigin, otherWindow) { | |
if (!targetOrigin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# slave 10.0.1.3 | |
sudo /etc/init.d/postgresql stop | |
sudo bash -c "rm -r /var/lib/postgresql/9.1/main/pg_xlog/*" | |
# master 10.0.1.2 | |
sudo su - postgres | |
psql -c ";SELECT pg_start_backup('backup', true)"; | |
rsync -av --rsync-path "sudo rsync" --exclude postmaster.pid --exclude pg_xlog /var/lib/postgresql/9.1/main/ [email protected]:/var/lib/postgresql/9.1/main/ | |
psql -c ";SELECT pg_stop_backup()"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
import requests | |
# Top Django site's from djangoproject.com, stackoverflow.com, and quora.com. | |
# I've determined the two unknowns, rdio.com and washingtonpost.com, are nginx. | |
urls = [ | |
'http://djangoproject.com/', | |
'http://disqus.com/', | |
'http://instagram.com/', | |
'http://addons.mozilla.org/', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
current_dir = File.dirname(__FILE__) | |
chef_repo_dir = File.dirname(current_dir) | |
home_dir = ENV["HOME"] | |
user = ENV["CHEF_USER"] || ENV["USER"] | |
server_url = ENV["CHEF_SERVER_URL"] | |
orgname = ENV["OPSCODE_ORGNAME"] | |
node_name user | |
client_key File.join(current_dir, "#{user}.pem") | |
cookbook_path [File.join(chef_repo_dir, "cookbooks")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.gis.db import models | |
from django.contrib.auth.models import UserManager, AbstractUser | |
class UserManager(UserManager, models.GeoManager): | |
pass | |
class User(AbstractUser): | |
objects = UserManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting | |
chflags nohidden $HOME/Library | |
export EDITOR="subl -w" | |
export ARCHFLAGS="-arch x86_64" | |
export PYTHONDONTWRITEBYTECODE=1 | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from git import Repo as GitRepo | |
repo = GitRepo(os.path.dirname(__file__)) | |
VERSION = (2, 0, 0, 'Codename', 'beta', repo.head.commit.hexsha[:8]) |