Skip to content

Instantly share code, notes, and snippets.

View driesdesmet's full-sized avatar

Dries Desmet driesdesmet

View GitHub Profile
stages:
- build
- test
- deploy
build:
stage: build
image: node:lts
script:
- npm install
@driesdesmet
driesdesmet / django-how.py
Last active April 27, 2016 15:47
Django queryset - how is this possible?
courses1 = Course.objects.filter(status='open').filter(site=Site.objects.get_current()).prefetch_related('teachers', 'accompanists').order_by('coursehours__starthour')
len(courses1.values())
# 500
courses2 = Course.objects.filter(status='open').filter(site=Site.objects.get_current())
len(courses1.values())
# 44
@driesdesmet
driesdesmet / forms.py
Last active December 3, 2015 16:39
Saving a Modelform subclass
class ContactForm(forms.ModelForm):
def save(self, **kwargs):
contact = super(ContactForm, self).save(kwargs)
contact.send_email()
return contact
class Meta:
model = Contact
fields = '__all__'
@driesdesmet
driesdesmet / 0006_auto_20150827_1703.py
Created August 27, 2015 15:19
Django migration not runnen
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def mark_teachers_as_staff(apps, schema_editor):
Profile = apps.get_model('profiles', 'Profile')
import pdb; pdb.set_trace
for profile in Profile.objects.filter(user_ptr__groups__name__in=['lesgevers', 'begeleiders']):
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from cms.models.pluginmodel import CMSPlugin
def addconfig(apps, schema_editor):
# Existing Quote Plugins don't have a configuration model, they use the default CMSPlugin, but now they should be
# using RandomQuotePlugin which stores the amount of quotes to show. We add a default of 1, to make it backwards
@driesdesmet
driesdesmet / version.py
Last active August 29, 2015 14:03 — forked from dcreager/version.py
# -*- coding: utf-8 -*-
"""Calculates the current version number.
If possible, uses output ofgit describemodified to conform to the
visioning scheme that setuptools uses (see PEP 386). Releases must be
labelled with annotated tags (signed tags are annotated) of the following
format:
v<num>(.<num>)+ [ {a|b|c|rc} <num> (.<num>)* ]
@driesdesmet
driesdesmet / gist:10665337
Created April 14, 2014 16:59
dump and restore with clearing a postgres database
pg_dump -c -U littleball littleball > /home/urga/littleball.sql
psql -U littleball_develop < /home/urga/littleball.sql
@driesdesmet
driesdesmet / gist:9248082
Last active August 29, 2015 13:56
how to use gettext with php
find . -iname "*.php" > /tmp/my_theme_file_list.txt
xgettext --from-code=utf-8 -f /tmp/my_theme_file_list.txt --keyword=__ --keyword=_e --keyword=_n -o lang/roots.pot
{
"color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
// Gebruik het Flatland kleurenschema voor code.
"ensure_newline_at_eof_on_save": true,
// Maak altijd een newline op het einde van een bestand.
"file_exclude_patterns":
[
"*.scssc",
"*.DS_Store"
],