Skip to content

Instantly share code, notes, and snippets.

@mkubenka
mkubenka / api.py
Created March 12, 2013 11:52 — forked from marteinn/api.py
from tastypie.exceptions import NotFound
from tastypie.resources import ModelResource
from tastypie.authentication import BasicAuthentication, ApiKeyAuthentication
from tastypie.models import ApiKey
from django.contrib.auth.models import User
__author__ = 'martinsandstrom'
class ApiTokenResource(ModelResource):
@paraboul
paraboul / command line
Created March 14, 2012 16:03
JavaScript + C Preprocessor
/usr/bin/cpp -P -undef -Wundef -std=c99 -nostdinc -Wtrigraphs -fdollars-in-identifiers -C < foo.js
(ns diagrams.core
(:require [hiccup.core :as h]))
(let [prelude "<?xml version=\"1.0\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.0//EN \" \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd \">\n"]
(defn svg-str
[contents]
(str prelude (h/html [:svg {:height 400 :width 400 :xmlns "http://www.w3.org/2000/svg"} contents]) "\n")))
(defn circle
[x y r & {:as attrs}]
@marteinn
marteinn / api.py
Created September 8, 2012 14:33
Tastypie and ApiToken resource example
from tastypie.exceptions import NotFound
from tastypie.resources import ModelResource
from tastypie.authentication import BasicAuthentication, ApiKeyAuthentication
from tastypie.models import ApiKey
from django.contrib.auth.models import User
__author__ = 'martinsandstrom'
class ApiTokenResource(ModelResource):