Skip to content

Instantly share code, notes, and snippets.

View joshfriend's full-sized avatar

Josh Friend joshfriend

View GitHub Profile
@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;
@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

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 / 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.
"""
@joshfriend
joshfriend / keybase.md
Created March 20, 2015 18:47
Keybase Proof

Keybase proof

I hereby claim:

  • I am joshfriend on github.
  • I am joshfriend (https://keybase.io/joshfriend) on keybase.
  • I have a public key whose fingerprint is A93F 8A25 F5BB 4C10 2EE1 B07B 7B43 92AD DFFD ACD2

To claim this, I am signing this object:

@joshfriend
joshfriend / Makefile
Last active August 29, 2015 14:16
Angular Project Template
NODE_DIR := ./node_modules
APP_DIR := ./app
BUILD_DIR := ./build
BOWER_DIR := bower_components
APP_SCRIPTS_DIR := $(APP_DIR)/scripts
APP_STYLES_DIR := $(APP_DIR)/styles
BIN := $(shell npm bin)
BOWER := $(BIN)/bower
UGLIFYJS := $(BIN)/uglifyjs
@joshfriend
joshfriend / .stashrc
Created February 16, 2015 18:09
Git command to create pull requests in Stash
STASH_DEFAULT_USERS="@joshfriend @user2 @user3"
STASH_DEFAULT_BRANCH=develop
@joshfriend
joshfriend / start-beat.sh
Last active August 29, 2015 14:14
celery once test
#!/bin/bash
python tasks.py beat
@joshfriend
joshfriend / resource.py
Last active August 29, 2015 14:08
Magicks to make Flask MethodViews more testable
class Resource(MethodView):
"""
Represents an abstract RESTful resource. Concrete resources should
extend from this class and expose methods for each supported HTTP
method. If a resource is invoked with an unsupported HTTP method,
the API will return a response with status 405 Method Not Allowed.
Otherwise the appropriate method is called and passed all arguments
from the url rule used when adding the resource to an Api instance. See
:meth:`~flask.ext.restful.Api.add_resource` for details.
"""
@joshfriend
joshfriend / jsontestclient.py
Created September 17, 2014 15:34
JSON client wrapper for Flask testing
#!/usr/bin/env python
import json
from flask.testing import FlaskClient
class JSONTestClient(FlaskClient):
"""Use by setting:
app.test_client_class = JSONTestClient