Skip to content

Instantly share code, notes, and snippets.

@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
<!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;
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"
@absent1706
absent1706 / api.py
Last active September 26, 2016 14:58
python-gae-api-oauth-no-servie-account
'''
code is taken from
https://github.com/GoogleCloudPlatform/storage-file-transfer-json-python
'''
from server.settings import current_environment as env
from server.errors import InternalError
import httplib2
from apiclient.discovery import build as discovery_build
from oauth2client.file import Storage as CredentialStorage
import re
from cgi import escape
def index(environ, start_response):
"""This function will be mounted on "/" and display a link
to the hello world page."""
start_response('200 OK', [('Content-Type', 'text/html')])
return ['''Hello World Application
This is the Hello World application:
@absent1706
absent1706 / db.sql
Last active October 18, 2016 15:22
Select products with grade order between grade_from and grade_to ( grade_from_id and grade_to_id can be nulls)
-- --------------------------------------------------------
-- Host: 127.0.0.1
-- Server version: 10.1.8-MariaDB - mariadb.org binary distribution
-- Server OS: Win32
-- HeidiSQL Version: 9.3.0.4984
-- --------------------------------------------------------
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@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
@absent1706
absent1706 / php-reflect-private-properties.php
Created November 14, 2016 12:17
PHP: Reflect provate properties
<?php
/* Returns all properties og object including private/protected
* in [prop => value] array
*/
function props($obj) {
$reflect = new \ReflectionClass($obj);
$props = $reflect->getProperties();
$result = [];
foreach ($props as $prop) {
@absent1706
absent1706 / config-symfony.php
Last active November 14, 2016 15:03
PsySH config file which teaches PsySH how to dump Eloquent model and collection (http://www.qopy.me/D6R2fYEQSw6wjV7NDaPMxw)
<?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
*/
@absent1706
absent1706 / config.php
Created January 11, 2017 13:27
psysh/config.php
<?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
*/