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
def truncate_db(engine): | |
# delete all table data (but keep tables) | |
# we do cleanup before test 'cause if previous test errored, | |
# DB can contain dust | |
meta = MetaData(bind=engine, reflect=True) | |
con = engine.connect() | |
trans = con.begin() | |
con.execute('SET FOREIGN_KEY_CHECKS = 0;') | |
for table in meta.sorted_tables: | |
con.execute(table.delete()) |
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
@echo off | |
set "ROOT_DIR=E:\code\knowstory" | |
set "VIRTUAL_ENV=%ROOT_DIR%\env" | |
if defined _OLD_VIRTUAL_PROMPT ( | |
set "PROMPT=%_OLD_VIRTUAL_PROMPT%" | |
) else (#!E:\Python\python.exe | |
import re | |
import sys |
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
<?php | |
/* | |
PsySh config file (see http://psysh.org/#configure) | |
!!! | |
Copy this file to ~\.config\psysh\config.php, where ~ is your home dir | |
for example (Windows): C:\Users\MY_USER\.config\psysh\config.php | |
Result dump will look like http://www.qopy.me/D6R2fYEQSw6wjV7NDaPMxw | |
*/ | |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<style> | |
[data-toggle="collapse"][aria-expanded="true"] > .js-rotate-if-collapsed | |
{ | |
-webkit-transform: rotate(180deg); |
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
/* | |
* Handler for reset button that cleans all form fields and submits form | |
* See http://www.javascript-coder.com/javascript-form/javascript-reset-form.phtml | |
*/ | |
$('.js-reset-closest-form').click(function() { | |
var form = $(this).closest('form')[0]; | |
/* it's important to take form.elements, not just $(form).find(input) | |
* because inputs can be OUTSIDE <form> tag, i.g.: | |
* <form id="search-form"> ... </form> | |
* ... |
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
def to_sql(query, dialect_name=None): | |
from sqlalchemy import dialects | |
import operator | |
if dialect_name: | |
dialect_module = getattr(dialects, dialect_name) | |
if not dialect_module: | |
raise KeyError('Wrong dialect {}'.format(dialect_name)) | |
dialect = dialect_module.dialect() | |
else: |
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
<!-- | |
See https://developers.google.com/api-client-library/javascript/samples/samples#authorizing-and-making-authorized-requests | |
for description and setup instructions | |
Key setup steps: | |
1. get client ID and API KEY http://www.qopy.me/0yILY0U8TD6kZ0ilhhoIAA | |
2. run HTTP server in folder where index.html lays. | |
I.g. PHP server: | |
php -S php -S 0.0.0.0:5000 | |
or this server (just EXE) http://www.zachsaw.com/?pg=quickphp_php_tester_debugger |
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
<!-- | |
See https://developers.google.com/identity/sign-in/web/ | |
for description and setup instructions | |
Key setup steps: | |
1. get client ID and API KEY http://www.qopy.me/0yILY0U8TD6kZ0ilhhoIAA | |
2. run HTTP server in folder where index.html lays. | |
I.g. PHP server: | |
php -S php -S 0.0.0.0:5000 | |
or this server (just EXE) http://www.zachsaw.com/?pg=quickphp_php_tester_debugger | |
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
from oauth2client import client, crypt | |
# (Receive token by HTTPS POST) | |
token = 'eyJhbGciOiJSUzI1NiIsImtpZCI6ImQyYzQ4YmFkMzAwMjBhY2U4MzBlZDkzYmQ4MWMzMjhkYzY4NTFhOTMifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJpYXQiOjE0ODc0MTc5ODEsImV4cCI6MTQ4NzQyMTU4MSwiYXRfaGFzaCI6IkIyYkJWU2d1M0tkOHdxT1p5NnN4Z3ciLCJhdWQiOiI1ODE3ODY2NTg3MDgtZWxmbGFua2VycXVvMWE2dnNja2FiYmhuMjVoY2xsYTAuYXBwcy5nb29nbGV1c2VyY29udGVudC5jb20iLCJzdWIiOiIxMDcwMzQzNjY2NTEwMjUwMzAwMDAiLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiYXpwIjoiNTgxNzg2NjU4NzA4LWVsZmxhbmtlcnF1bzFhNnZzY2thYmJobjI1aGNsbGEwLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwiZW1haWwiOiJsaXR2aW5lbmtvMTcwNkBnbWFpbC5jb20iLCJuYW1lIjoi0JDQu9C10LrRgdCw0L3QtNGAINCb0LjRgtCy0LjQvdC10L3QutC-IiwicGljdHVyZSI6Imh0dHBzOi8vbGg0Lmdvb2dsZXVzZXJjb250ZW50LmNvbS8tME9hYkNoaHZMU1kvQUFBQUFBQUFBQUkvQUFBQUFBQUFBLU0vUkFhaHlTaUE2aGsvczk2LWMvcGhvdG8uanBnIiwiZ2l2ZW5fbmFtZSI6ItCQ0LvQtdC60YHQsNC90LTRgCIsImZhbWlseV9uYW1lIjoi0JvQuNGC0LLQuNC90LXQvdC60L4iLCJsb2NhbGUiOiJydS1VQSJ9.LrL5ji_j-oX9Lh78TsoyJXzSQfUaQ3elxg8GOrsHwURxMAY7lbo |
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 os | |
import unittest | |
loader = unittest.TestLoader() | |
tests = loader.discover(os.path.join(os.path.dirname(__file__), | |
'sqlalchemy_mixins')) | |
testRunner = unittest.runner.TextTestRunner() | |
testRunner.run(tests) |