Skip to content

Instantly share code, notes, and snippets.

@cshireman
cshireman / BasicDataSource.swift
Created September 18, 2024 17:03
A task based data source that makes a JSON request to an API endpoint
//
// BasicDataSource.swift
// ShireWorkout
//
// Created by Chris Shireman on 9/18/24.
//
import Foundation
import UIKit
@cshireman
cshireman / AsyncDataSource.swift
Created September 18, 2024 16:46
My code to make a JSON request and process the response using AsyncAwait
//
// AsyncDataSource.swift
// ShireWorkout
//
// Created by Chris Shireman on 9/18/24.
//
import Foundation
class AsyncDataSource {
@cshireman
cshireman / fix-certbot.sh
Created July 8, 2020 15:13
Repair a certbot installation when python errors happen.
#!/bin/bash
sudo /opt/eff.org/certbot/venv/local/bin/pip install cryptography interface zope
function parseColor(color) {
// from http://www.bitstorm.org/jquery/color-animation/jquery.animate-colors.js
var match, triplet;
// Match #aabbcc
if (match = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(color)) {
triplet = [parseInt(match[1], 16), parseInt(match[2], 16), parseInt(match[3], 16), 1];
// Match #abc
} else if (match = /#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(color)) {
@cshireman
cshireman / phabricator_workflow.sh
Created August 15, 2014 18:57
BASH: Phabricator workflow bash functions
RELEASE_BRANCH=release/v2.0.0
# Shortcut replacement for fetching and rebasing into your current branch. This can be used either as a substitute for git pull, or a way to rebase changes from the primary branch into your local feature/bug branch.
# $1 = either 'dev' or 'rel' depending on which branch you want to rebase into your branch. If it is neither 'dev' or 'rel' then it should be a remote branch you want to rebase into your branch (e.g. origin/branch_name)
#
# Example usage: gitup dev
# Example usage: gitup rel
# Example usage: gitup origin/branch_name
gitup()
{
@cshireman
cshireman / gist:288426a6f8a09cbaa243
Created August 14, 2014 04:46
Titanium: Alloy viewDidAppear
//Equivalent to viewDidAppear. Have to use a state variable to make sure this is only called once.
$.hasAppeared = false;
$.getView().addEventListener("postlayout",function(){
if(!$.hasAppeared)
{
$.hasAppeared = true;
}
});
@cshireman
cshireman / gist:e5ad09eedd605957e064
Created August 14, 2014 04:10
Titanium: Header Comment
/**
* filename.js
* Description: File description goes here
* Author: Christopher Shireman
* Create Date: Today's Date
*/