Skip to content

Instantly share code, notes, and snippets.

View artemrizhov's full-sized avatar

Artem Rizhov artemrizhov

View GitHub Profile
@artemrizhov
artemrizhov / south_multidb.py
Created October 30, 2013 15:49
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:
#!/usr/bin/python
# Use Python formatting in Linux shell
import sys
print sys.argv[1].format(*sys.argv[2:])
@artemrizhov
artemrizhov / map_vs_count.exs
Created December 16, 2016 00:44
Compare Enum.map|>Enum.sum against Enum.count in Elixir (map won)
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
Output:
len = 10
map: 0.6671 µs
count: 2.5472 µs