Skip to content

Instantly share code, notes, and snippets.

@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):
(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}]
@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
@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):
#!/usr/local/bin/python3
# Created : 2020-07-16 13:06:10
import sys
import os
from graphviz import Digraph
fmt = os.getenv('GRAPH_FMT', 'dot')
dot = Digraph(comment='alembic', format=fmt)
@lecram
lecram / escher.py
Last active August 27, 2021 07:05
This is a toy one-file application to manage persistent key-value string data. The file is *both* the application and its data. When you run any of the commands described in `escher.py --help`, the file will be executed and, after data change, it will rewrite itself with updated data. You can copy the file with whatever name to create multiple d…
#! /usr/bin/env python
"""{escher} -- one-file key-value storage.
What?
This is a toy application to manage persistent key-value string data.
The file {escher} is *both* the application and its data.
When you run any of the commands below, the file will be executed and,
after data change, it will rewrite itself with updated data.
You can copy the file with whatever name to create multiple datasets.
@Nurdok
Nurdok / python_conversion.md
Last active December 16, 2022 03:45
Python Conversion

Python Number Conversion Chart

From To Expression
@Hupotronic
Hupotronic / h264-vs-vp8-test.md
Last active January 31, 2023 16:50
H.264 & VP8 Quality Comparison And Some Words on Future Video Formats

VP8 vs H.264 - Which One is Better?

So I was reading Hacker News and decided to read the comments in the thread about H.265 being approved. Pretty close to the top was this comment about VP9, Google's future video format. I have some words of my own about it and other future formats at the bottom of this post, but what jumped out from the comment to me was this part:

Many have already implemented VP8 (which is also slightly better than h.264 at this point)

The comparison linked to back up that statement is faulty for several reasons, such as not providing the source material used (hell, he doesn't even name the source material), exact encoding settings used (no, some random profiles are not enough), not providing the resulting encodes, only providing a

@danneu
danneu / golang-vs-clojure-async.md
Last active November 6, 2023 04:09
Google I/O 2012 - Go Concurrency Patterns ported to Clojure Video: http://www.youtube.com/watch?v=f6kdp27TYZs
@josephwecker
josephwecker / new_bashrc.sh
Created August 11, 2012 04:36
Replace .bashrc, .bash_profile, .profile, etc. with something much more clean, consistent, and meaningful. Now a repo: https://github.com/josephwecker/bashrc_dispatch
#!/bin/bash
# License: Public Domain.
# Author: Joseph Wecker, 2012
#
# -- DEPRICATED --
# This gist is slow and is missing .bashrc_once
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch
# (Thanks gioele)
#
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile?