Skip to content

Instantly share code, notes, and snippets.

View oduvan's full-sized avatar
✂️
Cleanup

Alexander Lyabah oduvan

✂️
Cleanup
  • CheckiO Inc.
  • United States
View GitHub Profile
@oduvan
oduvan / find_serialization_errors.py
Created June 10, 2011 14:32
www.lyabah.com Django find_serialization_errors
from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError
from django.core import serializers
from django.utils.datastructures import SortedDict
from optparse import make_option
class Command(BaseCommand):
option_list = BaseCommand.option_list + (
make_option('--format', default='json', dest='format',
from django import db
from django.conf import settings
from nose.plugins import Plugin
from django.test import TransactionTestCase
import uuid
import warnings
TEST_DB_PREFIX = settings.DATABASES['default']['NAME'] + '__'
def set_cur_db(db_name):
# pip install scipy
Collecting scipy
Downloading scipy-1.0.0.tar.gz (15.2MB)
100% |████████████████████████████████| 15.2MB 80kB/s
Complete output from command python setup.py egg_info:
ATLAS version 3.10.3 built by buildd on Tue Jan 17 22:59:14 UTC 2017:
UNAME : Linux x86-ubc-01 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1 (2016-12-30) x86_64 GNU/Linux
INSTFLG : -1 0 -a 1 -l 1
ARCHDEFS : -DATL_OS_Linux -DATL_ARCH_x86SSE2 -DATL_CPUMHZ=2297 -DATL_SSE2 -DATL_SSE1 -DATL_USE64BITS -DATL_GAS_x8664
F2CDEFS : -DAdd_ -DF77_INTEGER=int -DStringSunStyle
sudo pip3 install checkio-client
$ sudo pip3 install checkio-client
@oduvan
oduvan / cio_dump.py
Last active October 10, 2019 12:49
json for np.ndarray, range and Iterator
import numpy as np
import json
from collections.abc import Iterator, Sequence
class CiOJSEncoderEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, np.ndarray):
return obj.tolist()
if isinstance(obj, np.generic):
return obj.item()
@oduvan
oduvan / attack.js
Created December 7, 2019 13:00
basic attack code for JS in EmpireofCode.com
var commander = require("battle/commander.js");
// create craft object
var craftClient = new commander.CraftClient();
// command to craft - start landing units
craftClient.doLandUnits();
function unitLanded(data) {
// create unit object
var unitClient = new commander.UnitClient(data['id']);
@oduvan
oduvan / attack.py
Created December 7, 2019 13:06
basic code for Python in Empire of Code . com
from battle import commander
# create craft object
craft_client = commander.CraftClient()
# command to craft - start landing units
craft_client.do_land_units()
def unit_landed(data):
# create unit object
unit_client = commander.UnitClient(data['id'])
@oduvan
oduvan / battle.py
Created December 7, 2019 13:49
battle field configuration for Empire of Code
from gen import players, crystalite_farm, sentry_gun, command_center, attack_craft
PLAYERS = players([
command_center([28, 18], level=2),
crystalite_farm([25, 19], level=2),
sentry_gun('def_code.py', [27, 23], level=1),
attack_craft(1, 'attacker.py', unit_quantity=6)
])
@oduvan
oduvan / overwrite_default_connection.py
Created March 30, 2020 10:57
Switch django default connection inside of context. It is very useful when you use readonly replica in Jupyter for analytics, but time to time you need to implement changes in master db
from contextlib import ContextDecorator
from django.db import connections
class overwrite_default_connection(ContextDecorator):
prev_default = None
write_connection = None
def __init__(self, write_connection):
self.write_connection = write_connection