tel:+7-927-728-67-99
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
clForm and clFormInput working together. | |
With clForm you define context and with clFormInput | |
you customize simple form controls. | |
clForm could be nested. | |
Sample: | |
<form cl-form="package as packageForm" cl-form-prefix="delivery[legs_attributes][0][package_attributes]"> | |
<input cl-form-input="system_of_measurement" ng-model="package.system_of_measurement"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActiionController::Base | |
def preload_associations(*associations) | |
collection = get_collection_ivar | |
associations.each do |association| | |
ActiveRecord::Associations::Preloader.new(collection, association).run | |
end | |
set_collection_ivar collection | |
collection | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
langs = %w{bfkegkudem kfpozexksm owfmkcnyvl rahgdgzhwv bukisteksg fxjeegggdx qejjzctbti qvigekhpog bvsqmvedya ewrgfpfrlu | |
bzvuzuanzo zhxcmwkizu ohxyodxkyv oomrfibhfw fzegixttqa kxdzqivfhl hniomtqdqr apphyuifwj ujfcrapeyx djgrcxqrux | |
rvtvpxbnzx bziseafhdp mofuvdculv nffrquughc gwrrvndjur mvzqilbvpi mpptidaosr lfgaxqtduu ldyzyofyar xtgkueabdj | |
wqhmxhcasa yxeoufxrry sphdgsweik hhunpqjpnz fnkkbvirll ncdmbrcvqi hctoategou mqtdyycvun afncjfmngf wjxyvhcsuz | |
puefxeidio nyfllolsvw ghjygztrnv folnzvecis uvtannbdjx jurkwqiavv wmfpexcqch ugmptanwdn eslmaaefez jxqcpsvvwu | |
fellmtwzsw nixzgduncg vupbjbdqke olbdbzufhe pxygpqdwoi jkhjwnpvqz ywludqlmlw kqulfxgqiv wvujqpjjwt wkmwuyazjo | |
mqkqtwbzxv dfeleuxjlt rgoobzxbfr pyykqgaoid qcwdcogibq kwospdrebi fbyhvdjrey uakluudovp eglxbpqtkj nxqpeffrvb | |
rlehisdiuy rhhexyshob flpxyqcjcy indkhpjugw qaoclhadbf ctfhonsqll mvehaiypoq joegipqmds qsblkvrxky abmhqmwnxy | |
zduqzarnxr nuygfvuzge qapxbfzggm yhpeuenslm huknmeiolq noxfaqgmms qovhnrrkju kdvrccwzeh jsvdszywda ldqejpsnsk | |
bqhdoixppa pqpckcqthi r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gevent.monkey | |
gevent.monkey.patch_all() | |
from gevent.wsgi import WSGIServer | |
import pp | |
import ujson | |
pool = pp.PostgresConnectionPool("dbname=api-performance-challenge_development", maxsize=20) | |
HEAD = ('id', 'text', 'created_at', 'likes_count', 'liked') | |
def application(environ, start_response): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT array_to_json(array_agg(row_to_json(t))) | |
FROM | |
(SELECT id, text, Cast(created_at AS text), | |
likes_count, | |
CASE | |
WHEN l.value THEN TRUE | |
ELSE FALSE | |
END AS liked | |
FROM posts | |
LEFT OUTER JOIN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from importlib.machinery import ModuleSpec, SourceFileLoader | |
pundles = dict([item.strip() for item in line.split(',')] for line in open('Pundlerfile').readlines()) | |
class PundlerFinder(object): | |
def find_spec(self, fullname, path, target_module): | |
if path is not None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import code | |
>>> import dis | |
>>> def func(): | |
... d = {} | |
... d.update({'a': 2, 'b':3}) | |
... | |
>>> dis.dis(func.__code__) | |
2 0 BUILD_MAP 0 | |
3 STORE_FAST 0 (d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- import json | |
- def ku(text): | |
h2 | |
- yield text | |
p | |
- yield "Awesome" | |
!doctype/ | |
head | |
title "magic is a pony" |
Захотелось мне сделать шаблонизатор, чтобы как slim, теги чтобы автоматом закрывались и прочее. Красиво же так:
html
head
title
- yield "Плюшка!" + " Чашка чаю!"
Но и этого мне мало, хочу чтобы не было своего недоязыка, хочу чтобы просто питоновские конструкции. А кто захочет себе в ногу стрельнуть и бизнес логики в шаблоны навалить, то это проблема начинашек, мне зачем мучаться размазывая код вьюх в папки типа utils, template_tags и прочее?
А и еще можно кстати угореть так уж угореть - а пусть шаблоны через новый махнизм импорта в python 3 тянутся. И если надо что-то от другого шаблона себе вставить, то тоже пусть также работает.
OlderNewer