Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View LucasRoesler's full-sized avatar

Lucas Roesler LucasRoesler

View GitHub Profile
@LucasRoesler
LucasRoesler / rqperiodic.py
Created March 15, 2014 22:08
Demonstration of how to create cron like periodic tasks using python RQ (http://python-rq.org/), django_rq (https://github.com/ui/django-rq), rq_scheduler (https://github.com/ui/rq-scheduler)
# put in app/management/commands
from datetime import datetime
import importlib
import logging
from optparse import make_option
from django.conf import settings
from django.core.management.base import BaseCommand
import django_rq
@LucasRoesler
LucasRoesler / middleware.py
Last active June 27, 2023 17:01
A Django middleware that process JSON data into the appropriate GET or POST variable. I use this with AngularJS, by default POST requests are sent as JSON instead of the urlencoded data expected by Django.
class JSONMiddleware(object):
"""
Process application/json requests data from GET and POST requests.
"""
def process_request(self, request):
if 'application/json' in request.META['CONTENT_TYPE']:
# load the json data
data = json.loads(request.body)
# for consistency sake, we want to return
# a Django QueryDict and not a plain Dict.
@LucasRoesler
LucasRoesler / pretty_git_log
Created June 9, 2014 18:55
A pretty git log
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
### Keybase proof
I hereby claim:
* I am lucasroesler on github.
* I am theaxer (https://keybase.io/theaxer) on keybase.
* I have a public key whose fingerprint is A62A A0E7 B9A9 CD22 CF1B CAF4 2355 3DFF EDE5 F952
To claim this, I am signing this object:
@LucasRoesler
LucasRoesler / CommaSeparatedEmailField.py
Created June 29, 2015 17:06
CommaSeparatedEmailField
from django import forms
from django.utils.translation import ugettext_lazy as _
from django.core.validators import validate_email, EMPTY_VALUES
from django.forms.fields import Field
class CommaSeparatedEmailField(Field):
description = _(u"E-mail address(es)")
def __init__(self, *args, **kwargs):
self.token = kwargs.pop("token", ",")
@LucasRoesler
LucasRoesler / scim.yaml
Last active July 7, 2020 22:06
EB SCIM
swagger: '2.0'
info:
title: Teem User Provisioning API
version: "1.0.0"
contact:
url: https://teem.com/developers/
email: support@teem.com
# the domain of the service
host: app.teem.com
# will be prefixed to all paths
FORMAT: 1A
HOST: https://eventboard.io/api/v4
# Eventboard.io API Spec
The api specification for eventboard.io
# Data Structures
## Reservation Base (object)
+ id: 1 (number)
swagger: '2.0'
info:
title: Eventboard API
version: 4.0.0
contact:
url: https://eventboard.io/developers/
email: support@eventboard.io
host: eventboard.io
basePath: /api/v4
schemes:
@LucasRoesler
LucasRoesler / git_aliases.ini
Created October 2, 2016 17:22
Some helpful git aliases, add these to your ~/.gitconfig
[alias]
# common operations
cp = cherry-pick
ci = commit
co = checkout
br = branch
undo-commit = reset --soft HEAD~1
# log as a graph
graph = log --graph --oneline --decorate --all
[alias]
# common operations
cp = cherry-pick
ci = commit
co = checkout
br = branch
undo-commit = reset --soft HEAD~1
# sort branches by last update
b = "!git for-each-ref --sort='-authordate' --format='%(authordate)%09%(objectname:short)%09%(refname)' refs/heads | sed -e 's-refs/heads/--'"