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
| " My Neovim config | |
| " Maintainer: John DeSilvio | |
| """ ========================================================================= | |
| """ General ----------------------------------------------------------------- | |
| """ ========================================================================= | |
| " No backup |
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
| # If you come from bash you might have to change your $PATH. | |
| # export PATH=$HOME/bin:/usr/local/bin:$PATH | |
| # Path to your oh-my-zsh installation. | |
| export ZSH="/Users/JohnsMacBook/.oh-my-zsh" | |
| # Theme | |
| # See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes | |
| ZSH_THEME="spaceship" | |
| SPACESHIP_CHAR_SYMBOL="λ " |
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 property descriptor. | |
| A classproperty decorator for a class method that | |
| is analogous to a property decorator for an instance | |
| method. | |
| Example: | |
| class MyClass(object): |
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 datetime | |
| from functools import wraps | |
| from flask import Flask, jsonify, request, make_response | |
| from flask_sqlalchemy import SQLAlchemy | |
| from flask_marshmallow import Marshmallow | |
| from werkzeug.security import ( | |
| generate_password_hash, | |
| check_password_hash | |
| ) |
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 factory | |
| from flask import Flask, jsonify | |
| from flask_sqlalchemy import SQLAlchemy | |
| from flask_marshmallow import Marshmallow | |
| # Setup | |
| app = Flask(__name__) | |
| app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.db' | |
| db = SQLAlchemy(app) |
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
| """Database timestamp.""" | |
| from sqlalchemy.ext.compiler import compiles | |
| from sqlalchemy.sql import expression | |
| from sqlalchemy.types import DateTime | |
| class utcnow(expression.FunctionElement): # pylint: disable=invalid-name,too-many-ancestors | |
| """Current UTC timestamp function.""" |
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
| const userAgent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36' | |
| Object.defineProperty( | |
| window.navigator, | |
| 'userAgent', | |
| { | |
| value: userAgent, | |
| configurable: true | |
| } | |
| ) | |
| const { JSDOM } = require('jsdom') |
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 functools import wraps | |
| from enum import Enum | |
| def metadata_factory(field, enum=None): | |
| def metadata(value): | |
| if enum: | |
| assert enum[value] is not None | |
| def wrapped(fn): |
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
| # Count classes in code | |
| find my_dir -name '*.py' | | |
| xargs grep -h '^[[:space:]]*\(class\)\b' | | |
| sed 's/^[[:space:]]*//' | | |
| cut -d ' ' -f 2 | | |
| cut -d '(' -f 1 | | |
| while read class; do | |
| echo "`find my_dir -name '*.py' | | |
| xargs grep -l "\b$class\b" | | |
| wc -l` $class" |
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 Table, Column, Integer, ForeignKey | |
| class BaseStar(object): | |
| __database__ = '' | |
| __tableargs__ = {} | |
| _key = '' | |
| _key_type = None | |
| _prefix = '' |