This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# http://stackoverflow.com/questions/5574702/how-to-print-to-stderr-in-python | |
from __future__ import print_function | |
import sys | |
def eprint(*args, **kwargs): | |
print(*args, file=sys.stderr, **kwargs) | |
import errno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
From http://harkablog.com/inside-the-django-orm-aggregates.html | |
with a couple of fixes. | |
Usage: MyModel.objects.all().annotate(new_attribute=GroupConcat('related__attribute', separator=':') | |
""" | |
from django.db.models import Aggregate | |
from django.db.models.sql.aggregates import Aggregate as SQLAggregate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(rpn). | |
-export([eval/1, hypotenuse/2]). | |
-compile({parse_transform,do}). | |
-spec eval([Op]) -> stack_m(ok). | |
%% Interpreter for a simple stack-based language. | |
%% | |
%% Uses a custom stack_m monad, which is a trivial wrapper around state_m[1]. | |
%% It exports: | |
%% -spec pop() -> stack_m(A). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Copyright (c) 2008 Nick Gerakines <[email protected]> | |
%% | |
%% Permission is hereby granted, free of charge, to any person | |
%% obtaining a copy of this software and associated documentation | |
%% files (the "Software"), to deal in the Software without | |
%% restriction, including without limitation the rights to use, | |
%% copy, modify, merge, publish, distribute, sublicense, and/or sell | |
%% copies of the Software, and to permit persons to whom the | |
%% Software is furnished to do so, subject to the following | |
%% conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(date_util). | |
-compile(export_all). | |
epoch() -> | |
now_to_seconds(now()) | |
. | |
epoch_hires() -> | |
now_to_seconds_hires(now()) | |
. |