Skip to content

Instantly share code, notes, and snippets.

View tijs's full-sized avatar
👔
mostly on Bitbucket :(

Tijs Teulings tijs

👔
mostly on Bitbucket :(
View GitHub Profile
<?php
//...snip...
/**
* Update MoneyBird Contact
*
* Update and existing contact using the MoneyBird API
*
* @access private
* @return contact
@tijs
tijs / homebrew cmake error
Created February 10, 2011 18:31
error message when running "brew install cmake"
manilla:Formula tijs$ brew install cmake
==> Downloading http://www.cmake.org/files/v2.8/cmake-2.8.2.tar.gz
File already downloaded and cached to /Users/tijs/Library/Caches/Homebrew
==> Downloading patches
######################################################################## 100,0%
######################################################################## 100,0%
==> Patching
patching file Source/cmXCodeObject.cxx
patching file Source/cmGlobalXCodeGenerator.cxx
Hunk #1 succeeded at 2742 (offset 16 lines).
@tijs
tijs / gist:1035703
Created June 20, 2011 14:29
error: [Errno 32] Broken pipe
Exception happened during processing of request from ('127.0.0.1', 49776)
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/local/Cellar/python/2.7.1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/usr/local/Cellar/python/2.7.1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/Cellar/python/2.7.1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 570, in __init__
BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
@tijs
tijs / gist:1036549
Created June 20, 2011 20:50
saving an m2m field in one API call
# models.py
class Subscriber(models.Model):
country = CountryField()
first_name = models.CharField(max_length=100, blank=True, null=True)
surname = models.CharField(max_length=100, blank=True, null=True)
email = models.EmailField()
brands = models.ManyToManyField("Brand")
#forms.py
from django import forms
# The key associated to your site.
key: <edited out>
# Version control system used locally for your project.
vcs: git
# Framework to use on Gondor.
framework: django
# This path is relative to your project root (the directory gondor.yml lives in.)
@tijs
tijs / backends.py
Created December 16, 2013 14:58
Custom backend for case insensitive login with email address to prevent login failures for people who created their accounts on device that automatically uppercases input fields (i.e. iOS)
from __future__ import unicode_literals
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
class CustomModelBackend(ModelBackend):
"""
Subclass the default ModelBackend
"""
@tijs
tijs / celerybeat.conf
Last active December 31, 2015 12:49
Our standard celerybeat configuration. Replace { project }, { app } and { app settings } with relevant details. This will of course be different if you use a different project layout.
; ===========================================
; celery beat supervisor example for Django
; ===========================================
[program:celerybeat]
# note: the -s command to set a scheduler is not here since we set it in the settings.py
command = /home/deploy/{ project }/{ app }/venv/bin/python /home/deploy/{ project }/{ app }/{ app root }/manage.py celery beat --loglevel=INFO --settings={ app settings }
# the directory to be in while running this (the directory containing manage.py)
directory = /home/deploy/{ project }/{ app }/{ app root }
@tijs
tijs / celeryd.conf
Created December 16, 2013 15:51
Standard celeryd configuration. Replace { project }, { app } and { app settings } with relevant details. This will of course be different if you use a different project layout. Set autoscale depending on project scale. 4,2 is fine for small projects. For larger projects check celery docs for optimal configuration.
# the name of this service as far as supervisor is concerned
[program:celeryd]
# the command to start celery
command = /home/deploy/{ project }/{ app }/venv/bin/python /home/deploy/{ project }/{ app }/{ app root }/manage.py celery worker --autoscale=4,2 --loglevel=INFO --settings={ app settings }
# the directory to be in while running this
directory = /home/deploy/{ project }/{ app }/{ app root }
# the user to run this service as
@tijs
tijs / forms.py
Created December 16, 2013 16:05
Prevent iOS (and maybe other mobile OSs as well) from auto capitalizing your username field, which in a standard Django auth setup would prevent these people from signing up with their uncapitalized username (or email for custom backends) when they try to login later.
class LoginForm(AuthenticationForm):
""" Subclass the default AuthenticationForm and overwrite the username widget attributes """
def __init__(self, *args, **kwargs):
super(LoginForm, self).__init__(*args, **kwargs)
self.fields['username'].widget.attrs.update({'autocapitalize':'off', 'autocorrect': 'off'})
@tijs
tijs / Ubuntu-on-mac-mini.md
Created January 1, 2014 16:43
Installing Ubuntu on my Mac Mini (2009). Dual boot installation of Mac OS X Mavericks and Ubuntu 13.10
  1. Install rEFIt: http://refit.sourceforge.net/doc/c1s1_install.html

  2. Create a new FAT/DOS partition for the linux install (dual boot setup)

  3. Download the linux ISO, in this case: http://www.ubuntu.com/download/

  4. Convert the iso to a bootable img format:

    cd ~/Downloads hdiutil convert -format UDRW -o ubuntu-13.10-desktop-amd64.img ubuntu-13.10-desktop-amd64.iso

  5. Partition your USB stick as 'Free space' using Disk Uility

  6. Find the name of your USB 'disk' with diskutil: