Skip to content

Instantly share code, notes, and snippets.

View aklim007's full-sized avatar

Artyem Klimenko aklim007

View GitHub Profile
@aklim007
aklim007 / gist:670cac14dd39da6fd658cefa7370bfe2
Created February 27, 2018 07:37
Reset All Sequence Postgresql
SELECT 'SELECT SETVAL(' ||
quote_literal(quote_ident(PGT.schemaname) || '.' || quote_ident(S.relname)) ||
', COALESCE(MAX(' ||quote_ident(C.attname)|| '), 1) ) FROM ' ||
quote_ident(PGT.schemaname)|| '.'||quote_ident(T.relname)|| ';'
FROM pg_class AS S,
pg_depend AS D,
pg_class AS T,
pg_attribute AS C,
pg_tables AS PGT
WHERE S.relkind = 'S'
@aklim007
aklim007 / underscore.deepvalid.js
Created July 4, 2015 19:09
underscore mixin deep validator
/**
* @example
* _.deepValid({a: 1, b: 2}, {a: null, b: null})
* true
* _.deepValid({a: 1, b: 2}, {a: null, b: _.isArray})
* false
* _.deepValid({a: 1, b: {b: {b: 4}}, c: 4}, {a: null, b: {b: {b: null}}})
* true
* _.deepValid({a: 1, b: {b: {b: 4}}, c: 4}, {a: null, b: {b: {b: function(value){ return value < 3}}}})
* false
@aklim007
aklim007 / djforms_arrayfield.py
Last active February 10, 2016 06:21
Django forms ArrayField
# -*- coding=utf8 -*-
"""Django forms ArrayField"""
# Changelog:
# 2016-02-10 версия 0.1.3 Очепятки
# 2016-02-05 версия 0.1.2 Информация о лицензии
# 2015-07-20 версия 0.1.1 Мета данные модуля
from __future__ import unicode_literals
VERSION = (0, 1, 3)
__all__ = ['ArrayField']
__title__ = 'FormsArrayField'