Skip to content

Instantly share code, notes, and snippets.

View forgo's full-sized avatar
🎯
Focusing

Elliott Richerson forgo

🎯
Focusing
View GitHub Profile
@forgo
forgo / figure_format.m
Created October 13, 2015 23:19
MATLAB Figure Formatting Convenience Script
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% FILE: figure_format.m
% AUTHOR: Elliott Richerson
% DATE: March 4, 2009
%
% DESCRIPTION: This function takes no inputs and formats any figures before
% the 'figure_format' call is invoked. The formatter will attempt to
% identify the type of plot and automatically locate and format lines,
% axes, labels, title, legend, and surfaces. This is accomplished
% primarily through testing default property values.
@forgo
forgo / JSONExtension.swift
Created October 13, 2015 23:49
SwiftyJSON extension for reading *.json from main bundle.
//
// JSONExtension.swift
// Created by Elliott Richerson on 10/8/15.
//
import Foundation
import SwiftyJSON
extension JSON {
static func fromFile(name:String) -> JSON {
@forgo
forgo / ISO8601DateFormatter.swift
Last active October 14, 2015 00:43
An NSDateFormatter subclass for the cool kids.
//
// ISO8601DateFormatter.swift
// Created by Elliott Richerson on 10/9/15.
// References: http://nshipster.com/nsformatter/
// https://xkcd.com/1179/
// Example UTC String: "1987-01-03T00:00:00.000Z"
import Foundation
class ISO8601DateFormatter : NSDateFormatter {
@forgo
forgo / PlaceholderTextView.swift
Last active October 14, 2015 03:18
UITextView emulating UITextField placeholder behavior.
//
// PlaceholderTextView.swift
// Created by Elliott Richerson on 10/10/15.
//
import UIKit
class ExampleViewController: UIViewController {
@IBOutlet weak var textViewPlaceholder: PlaceholderTextView!
@forgo
forgo / Constants.swift
Created October 14, 2015 00:20
Swift global constants method using segmented sub structs
//
// Constants.swift
// Created by Elliott Richerson on 10/10/15.
//
// Example usage: Constant.Text.PlaceholderUsername
struct Constant {
struct Text {
static let PlaceholderUsername = "username"
static let PlaceholderPassword = "password"
@forgo
forgo / CustomNumberFormatter.swift
Last active October 14, 2015 00:43
NSNumberFormatter subclass convenience stub.
//
// CustomNumberFormatter.swift
// Created by Elliott Richerson on 10/9/15.
// References: http://nshipster.com/nsformatter/
//
import Foundation
class CustomNumberFormatter : NSNumberFormatter {
required init?(coder aDecoder: NSCoder) {
@forgo
forgo / SwiftSingleton.swift
Created October 25, 2015 23:36
Simple and concise singleton written in Swift.
//
// SwiftSingleton.swift
// Created by Elliott Richerson on 10/25/15.
//
import Foundation
class SwiftSingleton {
static let sharedInstance = SwiftSingleton()
private init() {}
@forgo
forgo / UIFontExtension.swift
Created October 30, 2015 23:31
UIFont extension with convenience helpers to aid in things like printing the installed fonts and their names.
//
// UIFontExtension.swift
// Created by Elliott Richerson on 10/30/15.
//
import UIKit
extension UIFont {
public static func printInstalledFonts() {
for fontFamily in UIFont.familyNames() {
@forgo
forgo / Video.jsx
Created November 18, 2017 22:10
Maintain Video Aspect Ratio in React
import React from "react";
export default class Video extends React.Component {
resize = () => {
// do work only if iframe exist
if (this.iframeRef) {
// recall our aspect ratio from props
const { aspectRatio } = this.props;
// get new width dynamically
@forgo
forgo / mapStructure.groovy
Created September 28, 2018 18:39
Debug Groovy Map Key Hierarchy
def mapStructure(Map map, int layer = 0) {
map.each { key, value ->
println "${('\t' * layer) + key}: ${layer.toString()}"
if(value.getClass() == LinkedHashMap.class) {
mapStructure((Map)value, layer+1)
}
}
}
// Example usage: