Skip to content

Instantly share code, notes, and snippets.

@absent1706
absent1706 / db_session.py
Last active November 8, 2016 13:05
DbSession + get updated/deleted, i.e. old values of some ORM attribute, say, KnowMix.attachment_id
from sqlalchemy.orm import sessionmaker, Session
class DbSession(Session):
def get_old(self, attr):
''' gets all old(updated/deleted) values of attribute '''
parent_class = attr.parent.class_
# take all attr values from deleted entities
# and all changed attr values from dirty entities
set "OLD_SQL_ALCHEMY_ECHO=%SQL_ALCHEMY_ECHO%"
set "SQL_ALCHEMY_ECHO=False"
set "OLD_CURRENT_ENV=%CURRENT_ENV%"
set "CURRENT_ENV=DEV"
mysqladmin -uroot -f drop knowstory && mysqladmin -uroot create knowstory
alembic upgrade head
python fake_data_db_generator\main.py
set "CURRENT_ENV=UNIT-TEST"
<!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" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<style>
.display-table-cell {
display: table-cell;
@absent1706
absent1706 / css-footer-at-bottom.css
Last active August 27, 2016 10:10
footer which is relative but in the bottom of the page
<iframe width="100%" height="300" src="//jsfiddle.net/aPv9H/626/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
@absent1706
absent1706 / html-bootstrap-search-starter.html
Created August 26, 2016 21:01
boostrap starter page with search field in navbar
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My project</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<style type="text/css">
.navbar-avatar {
padding-top: 7px !important;
padding-bottom: 7px !important;
@absent1706
absent1706 / framework.css
Created August 19, 2016 19:18
css-simple-bootstrap
/* Grid system */
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.container:after, .container:before, .row:after, .row:before {
content: " "; display: table;
}
// checks that all files in <input type="file"> have valid mime type (according to 'accept' attribute)
$.fn.filesHaveValidType = function() {
// this validation works for:
// 1. simple 'accept' values like 'image/*'
// 2. combined 'accept' values like accept="image/png, audio/mp3"
var elem = this[0];
var accept = this.attr('accept');
if (accept) {
var acceptTypes = accept.split(',').map(function(s) { return s.trim() });
// iterate over all files and return false if some file is of invalid type
@absent1706
absent1706 / composer.json
Last active August 2, 2016 09:59 — forked from spekkionu/composer.json
Standalone validation using laravel validation component
{
"require": {
"illuminate/validation": "~4.2.9"
},
}
@absent1706
absent1706 / activate.bat
Created July 27, 2016 10:38
GAE env files
@echo off
set "VIRTUAL_ENV=E:\Web.LOCAL\Python\projects\knowstory\env"
set "ROOT_DIR=E:\Web.LOCAL\Python\projects\knowstory"
if defined _OLD_VIRTUAL_PROMPT (
set "PROMPT=%_OLD_VIRTUAL_PROMPT%"
) else (
if not defined PROMPT (
set "PROMPT=$P$G"
)