Skip to content

Instantly share code, notes, and snippets.

@w495
w495 / cyrillic2latin_file_renamer.py
Created August 13, 2017 00:48 — forked from etrushkin/cyrillic2latin_file_renamer.py
Cyrillic to Latin File Changer
#!/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
@w495
w495 / aggregate_concat.py
Last active April 18, 2017 17:09 — forked from ludoo/aggregate_concat.py
Django aggregates GROUP_CONCAT support for MySQL
"""
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
@w495
w495 / rpn.erl
Created June 16, 2012 23:44 — forked from amtal/rpn.erl
Simple interpreter using a monad for a "mutable" environment.
-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).
@w495
w495 / memoize.erl
Created May 2, 2012 10:40 — forked from andrzejsliwa/memoize.erl
A small module to provide memoize functions in Erlang.
%% 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:
@w495
w495 / date_util.erl
Created November 10, 2011 07:23 — forked from zaphar/date_util.erl
set of utility functions that wrap the calendar module and erlangs now() date() and time() functions
-module(date_util).
-compile(export_all).
epoch() ->
now_to_seconds(now())
.
epoch_hires() ->
now_to_seconds_hires(now())
.