Skip to content

Instantly share code, notes, and snippets.

View tachyondecay's full-sized avatar

Kara Babcock tachyondecay

View GitHub Profile
<user_review>I read math books for fun. I realize that, right away, this puts me in an unusual portion of the population. It’s not &lt;em&gt;just&lt;/em&gt; my fancy math degree that makes these books attractive. However, I do think that there are some math books written for people interested in math (whether professionally or amateurly), and then there are math books written for people who, usually thanks to a bad experience in school, have sworn off math like they said they would swear off cheap booze. &lt;em&gt;Our Days Are Numbered&lt;/em&gt; is one of the latter. In a passionate and personal exploration of shape, algebra, geometry, and number, Jason I. Brown illuminates the fundamental mathematics behind some everyday tasks. While some people will still run away screaming, others will hopefully begin to see math in a new way.&lt;br /&gt;&lt;br /&gt;Among the topics Brown explores are: converting between units, using graphs to display data, the meaning behind averages, the role of chance in decision-makin
@tachyondecay
tachyondecay / datetimeform.py
Last active April 22, 2022 16:53
DateTimeForm: Combined date/time HTML5 inputs for WTForms
import datetime
from wtforms import Form, StringField
from wtforms.fields.html5 import DateField
from wtforms.widgets.html5 import TimeInput
class TimeField(StringField):
"""HTML5 time input."""
widget = TimeInput()
@tachyondecay
tachyondecay / SassMeister-input.scss
Last active August 29, 2015 14:14
Generated by SassMeister.com.
// ----
// Sass (v3.4.11)
// Compass (v1.0.3)
// ----
// Generates background properties for Cartesian axes in specified quadrant
@mixin axes($q: 1, $bg-colour: rgba(#fff,0.5), $pad: 0.5em) {
// Define pairs for x-axis position. y-axis is always opposite
$x-pairs: ((bottom, right), (bottom, left), (top, left), (top, right));
// Define quadrants in which each axis is inverted
@tachyondecay
tachyondecay / gist:4dcc0490a1e3a87e3e84
Created March 30, 2015 01:38
jQuery from CDN with local fallback
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.11.2.min.js"><\/script>')</script>
@tachyondecay
tachyondecay / gist:92e8eb1b24b6f113d3fa
Created June 21, 2015 21:52
Add your own border colour to an embedded Twitter timeline
.twitter-timeline {
border: 1px solid blue !important; /* Replace "blue" with another named colour or hexadecimal color code of your choice. The "!important" flag prevents the inline styling from overriding this rule. */
border-radius: 5px; /* This makes the corners rounded slightly. */
}
@tachyondecay
tachyondecay / datetime-local.py
Last active March 8, 2024 09:18
DateTime WTForms field that assumes input is in local time and converts to UTC for storage
# Requires Arrow package
class DateTimeWidget:
"""Widget for DateTimeFields using separate date and time inputs."""
def __call__(self, field, **kwargs):
id = kwargs.pop('id', field.id)
date = time = ''
if field.data:
dt = arrow.get(field.data).to(current_app.config['TIMEZONE'])
date = dt.format('YYYY-MM-DD')
@tachyondecay
tachyondecay / logging_config.py
Created January 7, 2016 23:54
Logging for Flask app
logging_config = {
"version": 1,
"disable_existing_loggers": False,
"formatters": {
"simple": {
"format": "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
}
},
"handlers": {
class Supplier(db.Model):
"""A supplier of consignment items."""
__tablename__ = 'consignment_suppliers'
id = db.Column(db.Integer, primary_key=True)
supplier_name = db.Column(db.String(200),
unique=True,
info={'label': 'Business name',
'filters': [lambda x: x or None]})
person_id = db.Column(db.Integer, db.ForeignKey('person.id'))
@tachyondecay
tachyondecay / twitter.css
Created May 22, 2016 16:00
Stylish sheets
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("twitter.com") {
.dashboard-right {
visibility: hidden;
}
.js-moments-tab {
visibility: hidden;
width: 0px;
}
@tachyondecay
tachyondecay / models.py
Last active July 7, 2024 09:00
Tags in Flask via SQLalchemy and association proxies
from app import db
from sqlalchemy import desc, event, func, orm
from sqlalchemy.ext.associationproxy import association_proxy
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy_utils import ArrowType, auto_delete_orphans
from slugify import slugify_unicode
tags = db.Table('tag_associations',
db.Column('tag_id', db.Integer, db.ForeignKey('tags.id')),
db.Column('article_id', db.Integer, db.ForeignKey('articles.id')))