Skip to content

Instantly share code, notes, and snippets.

View Znack's full-sized avatar

Sergey Cherepanov Znack

  • MetaLamp
  • Barcelona
View GitHub Profile

Keybase proof

I hereby claim:

  • I am znack on github.
  • I am znack (https://keybase.io/znack) on keybase.
  • I have a public key ASCMjsFgS48dOnbJp7zFv3BsggVMwdmFJHJUO6QIqrnG_wo

To claim this, I am signing this object:

@Znack
Znack / V0001 V0001CreateUserAndPostTables.hs
Created June 8, 2018 15:16
Illustrating beam migration problem about outdated relations
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE ImpredicativeTypes #-}
module Schema.Migrations.V0001CreateUserAndPostTables where
import Data.Text (Text)
@Znack
Znack / Example.js
Created February 28, 2018 14:41
Prototypes and Constructors
function Animal(name) {
this.name = name;
}
Animal.prototype.getName = function() {
return this.name;
}
Animal.prototype.sayHi = function() {
return "Hmmm...";
@Znack
Znack / TelegramHandlersRouter.hs
Created February 16, 2018 12:19
Servant-like handlers router for Telegram bots
{-# LANGUAGE DataKinds, TypeOperators #-}
{-# LANGUAGE TypeFamilies, FlexibleInstances, FlexibleContexts, ScopedTypeVariables
#-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE InstanceSigs #-}
module Router where
import Control.Applicative
import Control.Monad
@Znack
Znack / migrations.py
Created December 9, 2015 16:27
Custom operations in migrations
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def make_balance_nullable_forwards(apps, schema_editor):
Carrier = apps.get_model("carriers", "Carrier")
default_balance_carriers = Carrier.objects.filter(balance=0)
default_deposit_carriers = Carrier.objects.filter(deposit=0)
@Znack
Znack / remove-table.sql
Created December 8, 2015 05:13
Remove all tables in database, MYSQL
SET FOREIGN_KEY_CHECKS = 0;
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
FROM information_schema.tables
WHERE table_schema = 'DB_NAME';
SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
from django.core.urlresolvers import reverse
from django.utils.text import mark_safe
def add_link_field_to_related(target_model=None, field='', app='', field_name='link',
link_text=unicode):
def add_link(cls):
reverse_name = target_model or cls.model.__name__.lower()
def link(self, instance):
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"filters": {
"require_debug_false": {
"()": "django.utils.log.RequireDebugFalse"
}
},
"handlers": {
"mail_admins": {
This file has been truncated, but you can view the full file.
{"key":"I. Народное хозяйство","values":[{"key":"I. Народное хозяйство","values":[{"key":"I. Народное хозяйство","values":[{"key":"I. Народное хозяйство","values":[{"key":"1937","values":[{"name":"I. Народное хозяйство","year":"1937","union_budget":37026,"resp_budgets":2307.9,"local_budgets":4079.2,"total_budget":43413.1,"level":"I. Народное хозяйство","subLevel":"I. Народное хозяйство","subSubLevel":"I. Народное хозяйство"}]},{"key":"1938","values":[{"name":"I. Народное хозяйство","year":"1938","union_budget":44629.3,"resp_budgets":2423.1,"local_budgets":4671.2,"total_budget":51723.6,"level":"I. Народное хозяйство","subLevel":"I. Народное хозяйство","subSubLevel":"I. Народное хозяйство"}]},{"key":"1939","values":[{"name":"I. Народное хозяйство","year":"1939","union_budget":51513.4,"resp_budgets":3842.2,"local_budgets":5060.9,"total_budget":60416.5,"level":"I. Народное хозяйство","subLevel":"I. Народное хозяйство","subSubLevel":"I. Народное хозяйство"}]},{"key":"1940","values":[{"name":"I. Народное хозяйство"
@Znack
Znack / a.js
Created July 12, 2015 09:18
Import contacts
function importContact (phone, firstName, lastName) {
return MtpApiManager.invokeApi('contacts.importContacts', {
contacts: [{
_: 'inputPhoneContact',
client_id: '1',
phone: phone,
first_name: firstName,
last_name: lastName,
}],
replace: false,