Skip to content

Instantly share code, notes, and snippets.

@albertbori
albertbori / StackCollectionView.swift
Last active August 9, 2018 10:14
An example of a UICollectionView-like view made from UIStackViews for easy layout of small grids
//
// StackCollectionView.swift
//
// Created by Albert Bori on 6/23/17.
//
import UIKit
@IBDesignable
class StackCollectionView: UIView {
@albertbori
albertbori / LocalNotifications.swift
Created July 13, 2018 23:55
NotificationCenter alternative using enums and delegates (fully swift)
import Foundation
import PlaygroundSupport
//class that allows fully-swift weak reference storage for arrays/dictionaries
class Weak<T> {
private weak var _object: AnyObject?
var object: T? { return _object as? T }
init(object: T) {
_object = object as AnyObject
@albertbori
albertbori / Array+Diff.swift
Last active August 9, 2018 10:13
An extension for Swift Array that returns the difference between two arrays
//: Playground - noun: a place where people can play
extension Array where Element: Comparable {
/**
Compares array with passed array and returns the differences. Warning: Must be a set of data (no duplicate values)
- Parameter with: The new array to compare to the existing array
- Returns: A tuple with an array of added items and an array of removed items.
*/
func diff(with array: Array) -> (added: Array, removed: Array) {
let originalArray = self.sorted()
@albertbori
albertbori / LocalNotifications.swift
Last active July 13, 2018 23:43
NotificationCenter alternative using delegates (fully swift)
import Foundation
import PlaygroundSupport
//class that allows fully-swift weak reference storage for arrays/dictionaries
class Weak<T> {
private weak var _object: AnyObject?
var object: T? { return _object as? T }
init(object: T) {
_object = object as AnyObject
@albertbori
albertbori / README.md
Last active November 9, 2015 20:59
LINQ GroupByDate Reporting Extension

LINQ GroupByDate Reporting Extension

This IQueryable<T> extension saves a bit of time when writing a report that groups results by date. You can specify which timeframes to group by (day, week, month, year), or use the default automatic thresholds.

This method also accepts and corrects null dates based on the available results. It does this by performing a simple query to grab the starting date, if it's missing, before running the main report query.

Sample Usage

public class OrderCountRow: ReportingExtensions.ReportRow