Skip to content

Instantly share code, notes, and snippets.

struct Person {
let age: Int
let name: String
let hobbies: [String]
// Main initializer that takes all parameters directly and assigns values to (initializes) all properties above
init(name: String, age: Int, hobbies: [String]) {
self.name = name
self.age = age
import SwiftUI
import Combine
struct ContentView: View {
var body: some View {
TaskList(tasks: [
Task(id: 1, title: "Task 1", isCompleted: false),
Task(id: 2, title: "Task 2", isCompleted: false),
Task(id: 3, title: "Task 3", isCompleted: true),
@aerickson14
aerickson14 / gist:64fe21dea66535fae70bb951491df6e4
Created February 20, 2021 19:57
Multi select using onSelect callback
struct SelectHabitsView: View {
@State private var selectedHabits: Set<String> = []
let habits = ["H1", "H2", "H3"]
var body: some View {
List {
ForEach(habits, id: \.self) { habit in
HabitView(
@aerickson14
aerickson14 / CustomURLProtocol.swift
Created March 20, 2017 19:40
Custom URLProtocol monitoring URLRequests over a URLSession in Swift 3
import UIKit
class CustomURLProtocol: URLProtocol {
struct Constants {
static let RequestHandledKey = "URLProtocolRequestHandled"
}
var session: URLSession?
var sessionTask: URLSessionDataTask?
{
"name": "box2d",
"license": {
"type": "zlib"
},
"version": "2.3.0",
"summary": "Box2D is an open source C++ engine for simulating rigid bodies in 2D.",
"description": "Box2D is an open source C++ engine for simulating rigid bodies in 2D. Box2D is developed by Erin Catto and has the zlib license. While the zlib license does not require acknowledgement, we encourage you to give credit to Box2D in your product.",
"homepage": "http://www.cocos2d-iphone.org",
"authors": "Erin Catto",
@aerickson14
aerickson14 / predict.php
Created March 20, 2015 03:23
March Madness Predictor
<?
function createDivision($divSize) {
$matches = array();
for($i=1; $i<=$divSize/2; $i++) {
$j = $divSize-$i + 1;
$matches[] = [$i,$j];
}
return $matches;
// Photoshop Script to Create iPhone Icons from iTunesArtwork
//
// WARNING!!! In the rare case that there are name collisions, this script will
// overwrite (delete perminently) files in the same folder in which the selected
// iTunesArtwork file is located. Therefore, to be safe, before running the
// script, it's best to make sure the selected iTuensArtwork file is the only
// file in its containing folder.
//
// Copyright (c) 2010 Matt Di Pasquale
// Added tweaks Copyright (c) 2012 by Josh Jones http://www.appsbynight.com