Skip to content

Instantly share code, notes, and snippets.

View joshfriend's full-sized avatar

Josh Friend joshfriend

View GitHub Profile
@joshfriend
joshfriend / timestamp.py
Last active August 29, 2015 14:21
SQLAlchemy Hybrid Property wrapper to preserve timezones
#!/usr/bin/env python
from sqlalchemy.ext.hybrid import hybrid_property
from aniso8601.timezone import UTCOffset
def timestamp_with_timezone(timestamp_attr, timezone_attr):
"""Wraps a ``DateTime`` and ``Interval`` column pair to create datetime
storage that preserves the original timezone information.
"""

Git Workflow Guidelines

Branching

Branch names should:

  1. Follow [git-flow][gitflow] style, i.e. story branches begin with feature/, bugs with bugfix/, etc.
  2. Contain the JIRA ticket ID (if one exists) at the beginning of the branch name (but after the git-flow label)
  3. Have a descriptive name. For the example ticket with title _"As an admin
@joshfriend
joshfriend / commit-msg
Last active August 29, 2015 14:22
Some useful commit hooks
#!/usr/bin/env python
#
# A commit hook to validate commit messages based on the rules in this article:
# http://chris.beams.io/posts/git-commit/
import re
import sys
import string
import textwrap
from functools import wraps
@joshfriend
joshfriend / InvertedFillLineChart.java
Last active January 13, 2022 08:39
Inverted fill line chart
package com.example.ui.charting.charts;
import android.content.Context;
import android.util.AttributeSet;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.utils.FillFormatter;
import com.example.ui.charting.renderer.InvertedFillLineChartRenderer;
#!/usr/bin/env python
from flask import current_app
from werkzeug.security import (
generate_password_hash,
check_password_hash,
DEFAULT_PBKDF2_ITERATIONS,
)
FROM python:2.7.10
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
RUN apt-get install -y --no-install-recommends make git
@joshfriend
joshfriend / errorhandlers.py
Created May 25, 2016 20:18
Flask Error Handlers
#!/usr/bin/env python
from flask import jsonify, current_app
from werkzeug.datastructures import WWWAuthenticate
from werkzeug.http import HTTP_STATUS_CODES
from flask_principal import PermissionDenied
def _make_errorhandler(code):
@joshfriend
joshfriend / Semaphore.swift
Last active July 19, 2016 19:58
Semaphore wrapper for swift2
import Foundation
struct Semaphore {
typealias Signal = () -> Int
private let semaphore: dispatch_semaphore_t
init(count: Int = 0) {
self.semaphore = dispatch_semaphore_create(count)
@joshfriend
joshfriend / pokedomains.txt
Created July 25, 2016 12:44
Pokemon which happen to be valid domains
Charmander -> charmand.er
Blastoise -> blastoi.se
Caterpie -> caterp.ie
Butterfree -> butterfr.ee
Kakuna -> kaku.na
Pidgeotto -> pidgeot.to
Pikachu -> pikac.hu
Raichu -> raic.hu
Sandslash -> sandsla.sh
Nidorina -> nidori.na
@DatabaseTable(tableName = Address.TABLE)
class Address() : BaseModel() {
companion object {
const val TABLE = "address"
const val NUMBER = "number"
const val STREET = "street"
const val DIRECTION = "direction"
const val UNIT = "unit"
const val CITY = "city"