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
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x000000012256f760
Exception Codes: 0x0000000000000001, 0x000000012256f760
VM Region Info: 0x12256f760 is not in any region. Bytes after previous region: 299071329 Bytes before following region: 1289636000
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
CoreUI image data 110814000-110838000 [ 144K] r--/r-- SM=PRV
---> GAP OF 0x5eb1c000 BYTES
Stack Guard 16f354000-16f358000 [ 16K] ---/rwx SM=NUL
Exception Note: EXC_CORPSE_NOTIFY
Terminating Process: exc handler [2852]
const json = {
emoji = 'some text with a 🐠'
}
@tijs
tijs / keybase.md
Last active September 20, 2017 18:08

Keybase proof

I hereby claim:

  • I am tijs on github.
  • I am tijs (https://keybase.io/tijs) on keybase.
  • I have a public key ASBY6qmM_lVo_lwsVSSJoSDFiGcIpKnNI7-ZZvPCI985swo

To claim this, I am signing this object:

@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:

@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 / 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 / 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 / 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
"""
# 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 / 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