This file contains hidden or 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
Show hidden characters
[ | |
{ "keys": ["alt+shift+f"], "command": "reindent" }, | |
{ "keys": ["ctrl+alt+s"], "command": "toggle_side_bar" }, | |
{ "keys": ["ctrl+alt+p"], "command": "prompt_select_workspace" }, | |
{"keys": [ "ctrl+alt+z" ], "command": "insert_snippet", "args": { "name": "Packages/User/my-snippets/localize.sublime-snippet"} }, | |
] |
This file contains hidden or 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 time | |
from timeout import timeout | |
class Test(object): | |
@timeout(2) | |
def test_a(self, foo, bar): | |
print foo | |
time.sleep(1) | |
print bar | |
return 'A Done' |
This file contains hidden or 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 UserProduct(Base): | |
user_id = Column(BigInteger, ForeignKey('user.user_id'), | |
primary_key=True) | |
product_id = Column(BigInteger, ForeignKey('product.product_id'), | |
primary_key=True) | |
class Product(Base): | |
product_id = Column(BigInteger, primary_key=True) |
This file contains hidden or 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
<?php | |
// in app/Providers/AppServiceProvider | |
/*namespace App\Providers; | |
use Illuminate\Support\ServiceProvider; | |
class AppServiceProvider extends ServiceProvider | |
{*/ | |
public function boot() | |
{ | |
if (\App::environment('local')) { | |
\Event::listen('Illuminate\Database\Events\QueryExecuted', function ($query) { |
This file contains hidden or 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
""" | |
!!! Run tests by just typing 'python <this file>', not throw nosetests/your IDE | |
Before run these tests: | |
1) make sure that PhantomJS executable is in your PATH (type phantomjs in CLI) | |
for custom phantomjs location change PHANTOMJS_PATH | |
2) run app dev server and make sure that BASE_URL is equal to real URL | |
""" | |
import unittest |
This file contains hidden or 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
def find(db, id_): # db is better to be global IMHO | |
db.query(self.__class__).filter(self.__class__.__mapper__.primary_key[0] == id_).one() |
This file contains hidden or 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
from sqlalchemy.ext.declarative import declarative_base | |
Base = declarative_base() | |
from sqlalchemy import * | |
from sqlalchemy.orm import relationship, backref, joinedload | |
class Request(Base): | |
__tablename__ = 'request' |
This file contains hidden or 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
################################################################# | |
def compile_query(query): | |
return str(query.statement.compile(compile_kwargs={"literal_binds": True})) | |
################################################################# | |
############################## EXAMPLE ############################## | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import Column, Integer, String | |
from sqlalchemy import create_engine |
This file contains hidden or 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
from sqlalchemy import create_engine | |
from sqlalchemy import select | |
from sqlalchemy import MetaData, Table, Column, String, Integer | |
engine = create_engine("sqlite://") | |
metadata = MetaData() | |
user_table = Table('user', metadata, | |
Column('id', Integer, primary_key=True), | |
Column('username', String(50)), | |
Column('fullname', String(50)) |
This file contains hidden or 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
<?php | |
/* | |
Пример программного кода для работы с API сервиса Яндекс.Директ | |
В примере использован рекомендуемый синтаксис для работы с API сервиса Яндекс.Директ | |
на языке PHP с использованием протокола JSON и авторизацией по токенам. | |
Обращаем внимание, что все текстовые данные должны быть в кодировке UTF8 |