Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am deepwalker on github.
  • I am deepwalker (https://keybase.io/deepwalker) on keybase.
  • I have a public key ASDkugv9ze6vFeJkfbDi-9QcZfgAIhngF4vB2vFGI8wptQo

To claim this, I am signing this object:

set hidden
call plug#begin('~/.vim/plugged')
" Elixir
Plug 'elixir-editors/vim-elixir'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
@Deepwalker
Deepwalker / match.py
Created May 17, 2018 13:59
Something about matching for trafaret
import trafaret as t
groups = [
{'service': [{'guid': 'bla'}]},
{'service': []},
]
class Match(t.Trafaret):
@Deepwalker
Deepwalker / custom_django_join.py
Last active December 20, 2017 15:54
Custom joins for django. Probably works with 1.11 and 2.x.
class CustomFromSQL(object):
def __init__(self, sql):
self.sql = sql
def as_sql(self, compiler, connection):
return self.sql, []
def add_to_queryset(self, queryset):
alias = hash(self.sql)
# Django iterates over query.tables
import inspect
from dataclasses import dataclass, field
class Union(type):
def __new__(cls, name, bases, namespace, **kwds):
print('Init new Union')
new_namespace = {}
for attr_name, value in namespace.items():
print(name, value)
import os
import csv
import types
import asyncio
import json
import aiohttp
async def feed_elastic():
from webassets.filter import Filter
class AngularTemplatesFilter(Filter):
input_template = "$templateCache.put('%s', '%s');"
output_template = """
(function() {
angular.module('%s').run(['$templateCache', function($templateCache) {
%s
}]);
})();
<script type='text/javascript'>
function jivo_onLoadCallback() {
var clientId = '00' + (Math.random() * 1000000000000000000) + '.' + (new Date()).getTime();
ga(function (tracker) {
clientId = tracker.get('clientId'); // получение client id из Google Analytics
jivo_api.setUserToken(clientId);
if (console) console.log('cid from ga', clientId);
})
jivo_api.setUserToken(clientId);
if (console) {
@Deepwalker
Deepwalker / ga.js
Last active November 10, 2015 07:18
Комментарии относительно вставки скрипта GA для новичков
(function(win, docmnt, tagname, ga_link, ga_func_name, a, m) {
// записываем на объект window имя нашей ga функции, которая обычно 'ga'
win['GoogleAnalyticsObject'] = ga_func_name;
// присваиваем window.ga функцию, если она еще не создана
win[ga_func_name] = win[ga_func_name] || function() {
// инициализируем массив window.queue, если его еще нет
// и кладем в него параметры, с которыми вызвали ga(...arguments)
(win[ga_func_name].queue = win[ga_func_name].queue || []).push(arguments)
};
win[ga_func_name].l = 1 * new Date();
GET_KEY = lambda x: x[0]
def map_reduce(rows, mapper, reducer):
return (
reducer(key, (row[1] for row in rows))
for key, rows in groupby(sorted(mapper(rows), key=GET_KEY), GET_KEY)
)