Skip to content

Instantly share code, notes, and snippets.

@bcbroom
bcbroom / Voronoi-test.js
Created December 30, 2018 03:01
Trying to work through operations on Voronoi cells and edges. Very rough and needs to be cleaned up.
const canvasSketch = require('canvas-sketch');
const {Delaunay} = require('d3-delaunay');
const {Cell} = require('./cell');
const settings = {
dimensions: [ 2048, 2048 ]
};
const margin = 256;
@bcbroom
bcbroom / CustomCodable.playground
Created June 8, 2017 04:58
Using a generic struct to represent a top level object for JSON response for Swift 4's Codable protocol
import UIKit
let jsonDataEnclosed = """
{ "data" :
{
"name": "Monalisa Octocat",
"email": "support@github.com",
"date": "2011-04-14T16:00:49Z"
}
@bcbroom
bcbroom / CustomCodable.swift
Created June 8, 2017 04:45
Trying implementations of Swift 4's Codable protocol for JSON decoding. Looking at the case where JSON is returned with an extra top level tag, such as "data"
//: Playground - noun: a place where people can play
import UIKit
// Many API's return data wrapped in an outer tag, such as this
let jsonDataEnclosed = """
{ "data" :
{
"name": "Monalisa Octocat",
const { resolve } = require('path');
const webpack = require('webpack')
module.exports = {
entry: [
//'react-hot-loader/patch',
// activate HMR for React
'webpack-dev-server/client?http://localhost:8080',
// bundle the client for webpack-dev-server
@bcbroom
bcbroom / Animator.m
Created March 28, 2016 03:03
Custom view controller transition without alignment jump
// from animator.m
- (void)animatePush:(id<UIViewControllerContextTransitioning>)transitionContext {
// seems that all the steps here have specific orders
// add toVC to container view
// auto layout step on toVC after toVC added to container
// get image frames after AL step
// have to set toVC frame offscreen after grab final image frames
// backdrop view added to container, needs to be under toVC.view
@bcbroom
bcbroom / PDFGenerator.h
Created January 27, 2016 12:55
Generate a paginated PDF based on a NSString. Adds an image and person's name on the last page. Shared under MIT license.
//
// PDFGenerator.h
//
//
// Created by Brian Broom on 12/10/15.
// Copyright © 2015 Brian Broom. All rights reserved.
//
#import <Foundation/Foundation.h>
@bcbroom
bcbroom / CoreDataHelper.h
Last active August 29, 2015 13:56
Core Data Helper Class
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface CoreDataHelper :NSObject
@property (nonatomic, readonly) NSManagedObjectContext *context;
@property (nonatomic, readonly) NSManagedObjectModel *model;
@property (nonatomic, readonly) NSPersistentStoreCoordinator *coordinator;
@property (nonatomic, readonly) NSPersistentStore *store;