Skip to content

Instantly share code, notes, and snippets.


Artem Rizhov artemrizhov

View GitHub Profile
artemrizhov / map_vs_count.exs
Created Dec 16, 2016
Compare|>Enum.sum against Enum.count in Elixir (map won)
View map_vs_count.exs
defmodule Test do
@moduledoc """
Tested with:
Erlang/OTP 19 [erts-8.1] [source-e7be63d] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.3.4
len = 10
map: 0.6671 µs
count: 2.5472 µs
View pyformat
# Use Python formatting in Linux shell
import sys
print sys.argv[1].format(*sys.argv[2:])
artemrizhov /
Created Oct 30, 2013
This adds multiple databases support to South. Import the module in your migration. Set `database` attribute on your migration class to the alias of db that you want to use. Access the database api via self.db.
from south import db as db_module
from south.migration.migrators import Migrator, DryRunMigrator
def with_db(run_migration):
def run_migration_with_db(self, migration, database):
migration_db = getattr(migration._migration.Migration,
'database', None)
if migration_db is not None: