Skip to content

Instantly share code, notes, and snippets.

View glenrobertson's full-sized avatar
💭
Taking the specifications from the customer to the Software Engineers

Glen Robertson glenrobertson

💭
Taking the specifications from the customer to the Software Engineers
View GitHub Profile
@glenrobertson
glenrobertson / git_branch_jira_in_progress.sh
Last active July 24, 2024 14:18
Create git branch for JIRA issue and mark in progress
export JIRA_USERNAME="JIRA_EMAIL";
export JIRA_API_KEY="API_KEY"; # Get key at https://id.atlassian.com/manage-profile/security
export JIRA_DOMAIN="example.atlassian.net"
export JIRA_PROJECT="PROJECT"
function j() {
git add .;
git stash;
local ticket_id="$JIRA_PROJECT-$1"
if ! git checkout -b $ticket_id 2>/dev/null; then
@glenrobertson
glenrobertson / download-image.py
Last active August 10, 2024 15:48
Pimoroni Inky image download script
"""
Set a cron job to run this script every 5 minutes
It will download the image from the given URL and render it.
The ETag header is used to check if the image has changed.
If it has, the image is downloaded and rendered.
If not, the script exits early.
The ETag is saved to a file and checked on the next run.
Requires pimoroni/inky library: https://github.com/pimoroni/inky#installation
@glenrobertson
glenrobertson / blink_gym_home_assistant.yaml
Created January 21, 2024 22:41
Blink gym capacity home assistant sensor
@glenrobertson
glenrobertson / boot.py
Last active December 29, 2022 01:33
MatrixPortal M4 up/down switch to toggle filesystem read-only/write modes
# This script allows the MatrixPortal M4 to switch between:
# 1. readonly mode: write to drive when connected to computer over USB C (Down button)
# 2. write mode: CircuitPython can write to itself (Up button)
# Useful when developing code to pair Wifi networks.
# Think of "down" button as developer mode (code cannot write to file system)
# and "up" button as production: (code can write to file system)
#
# After hitting "reset" button twice, or reconnecting USB-C cable:
# neopixel will flash orange three times, then teal when accepting up/down button press
# blue indicates readonly mode
@glenrobertson
glenrobertson / extract_digits.py
Created June 11, 2017 01:11
Convert transcript to list of digits
import sys
import re
words_to_digits = {
'zero': 0,
'one': 1,
'two': 2,
'three': 3,
'four': 4,
'five': 5,
@glenrobertson
glenrobertson / ballgametoday.py
Last active September 10, 2016 06:49
Ball game today AWS lambda slack webhook
import boto3
from base64 import b64decode
from urlparse import parse_qs
import logging
import urllib2
import json
logger = logging.getLogger()
logger.setLevel(logging.INFO)
@glenrobertson
glenrobertson / data_required_if.py
Created June 15, 2015 21:09
Conditional DataRequired wtforms validator
class DataRequiredIf(wtforms.validators.DataRequired):
"""
Similar to DataRequired
Only evaluates if func(form.data) evaluates to True
"""
def __init__(self, func, *args, **kwargs):
super(DataRequiredIf, self).__init__(*args, **kwargs)
self.func = func
def __call__(self, form, field):
@glenrobertson
glenrobertson / index.html
Last active August 29, 2015 14:03
Map with TMS params
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<style type="text/css">
html, body, #map {
margin: 0;
padding: 0;
@glenrobertson
glenrobertson / flask_cache_response_decorator.py
Last active January 15, 2022 21:15
Flask response cache decorator
import datetime
import time
from functools import wraps
from wsgiref.handlers import format_date_time
from flask import make_response
def cache(expires=None, round_to_minute=False):
"""
Add Flask cache response headers based on expires in seconds.
@glenrobertson
glenrobertson / index.html
Last active December 26, 2019 23:24
so tile much random wow
<!DOCTYPE html>
<html>
<head>
<title>Stupid Map</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script>
<style type="text/css">