This code is a sample for a question on Stackoverflow about making multisite user models with Django 1.7.
Add these lines to your settings file:
AUTH_USER_MODEL='s1.Member'
SITE_ID = 1
AUTHENTICATION_BACKENDS = ( 'MyApp.MyModule.MyModelBackend',)
This code is a sample for a question on Stackoverflow about making multisite user models with Django 1.7.
Add these lines to your settings file:
AUTH_USER_MODEL='s1.Member'
SITE_ID = 1
AUTHENTICATION_BACKENDS = ( 'MyApp.MyModule.MyModelBackend',)
@task | |
def listlocaldbs(): | |
""" | |
list dbregistry in $HOME/dbregistry.txt | |
""" | |
registryfile = os.path.expanduser('~/dbregistry.txt') | |
with open(registryfile, 'r') as f: | |
print f.read() |
After reading Code Climate's Rails' Insecure Defaults I realized I was guilty of breaking rule 3. Versioned Secret Tokens. Here's how I fixed it.
Use dotenv in development and test environments:
# Gemfile
gem 'dotenv-rails', groups: [:development, :test]
# dokku remote command | |
function dz() { | |
case $1 in | |
push) | |
# top level git directory | |
LOCAL_BRANCH="$(git branch -l 2>/dev/null | grep '\*' | awk '{print $2}')" | |
if [ -d .git ]; then | |
echo "Pushing branch $LOCAL_BRANCH to dz master" | |
git push dz $LOCAL_BRANCH:master | |
else |
> inxi -S
System: Host: MY_HOSTNAME Kernel: 3.5.0-19-generic x86_64 (64 bit) Desktop: Gnome Distro: Linux Mint 14 Nadia
# find the commits you want to remove, e.g. using all commits that added or changed a file
$ git whatchanged -- path/to/file [...] > files.lst
$ git whatadded -- path/to/file [...] >> files.lst
# then do a rebase to get all commits that were added since then, including the ones you want to exclude
$ git rebase -i <commit>
# when rebase stops it will have created .git/rebase-merge/git-rebase-todo
# then do the following. this will take the commit ids from files.lst and
# remove every line in git rebase-todo
$ cat files.lst | cut -b1-7 | xargs -L1 -I {} sed -i '/{}/d' /home/patrick/projects/shrebo-ext/.git/rebase-merge/git-rebase-todo
# -*- coding: utf-8 -*- | |
# (c) 2014 one2seven GmbH, Switzerland | |
import urllib | |
import json | |
import sys | |
def geocode_by_osm(address): | |
""" | |
geocode an address using openstreet map | |
""" |
Currently there seem to be different ways for attached services. Some prefer to attach a service (e.g. rabbitmq) to a single app by default, while the dokku-link plugin allows one service to be linked to multiple apps. Also there are various ways for service plugins to name their environment variables. | |
This is to propose a standard for attached services, as follows. Ammendments, feedback and proposals welcome. | |
1. A service is a dokku-plugin that, upon plugin installation, builds a base image to run the service in its own container. | |
2. A service can be linked to any number of dokku apps, but it can also be created without any app specified (deferred linking). | |
3. When linked, the service is to expose its connection URL to app containers as a single environment variable that follows this dokku-args standard: `-e <SERVICE>_URL=<service>://<user>:<password>@<ip>[/<path>]`, where service is the service name (e.g. MYSQL, RABBITMQ etc.), user/password the access credentials or tokens, ip the linked container's addr |
class ClientRequestTracer(object): | |
""" | |
Trace api calls to a test client | |
Usage: | |
self.client = ClientRequestTracer(self.client) | |
self.api_client = ClientRequestTracer(self.api_client) | |
Limit the traces by giving parameter traces=[...] list of | |
strings 'get', 'post', 'put' |
""" | |
(c) 2015 github.com/miraculixx | |
MIT License | |
Cacheable URL getter for Django | |
Uses Django's cache framework to cache responses with the same URL. | |
Usage: | |
url = 'http://www.domain.com/static/content' |