Skip to content

Instantly share code, notes, and snippets.

@SlappyAUS
SlappyAUS / WatchkitButtonStyle.swift
Created November 24, 2020 01:59
Watchkit Button Style #swiftui #watchos
struct ContentView: View {
@State private var EnrouteText = "Enroute"
var body: some View {
List {
Button(action: {
self.EnrouteText = getCurrentTime()
}) {
Text(EnrouteText)
}
.buttonStyle(BtnStyle(bgColor: .red, fgColor: .white))
@SlappyAUS
SlappyAUS / watchkit_lists.swift
Created November 22, 2020 09:17
WatchKit Lists #watchkit #ui #swiftui #ios #swift
//
// ContentView.swift
// FirstWatch WatchKit Extension
//
// Created by Greg Eales on 22/11/20.
//
import SwiftUI
struct Person: Identifiable, Equatable {
@SlappyAUS
SlappyAUS / hideKeyboard.swift
Last active November 18, 2020 08:05
Hide Keyboard #swift #swiftui #ui
// Add to View Struct
@State private var editing = false
// TextField Definition
TextField("", text: dailyIntakeGoalString) { (change) in
self.editing = true
} onCommit: {}
// Attach to Parent View
.gesture(TapGesture().onEnded { _ in
@SlappyAUS
SlappyAUS / DateAggegation.swift
Created November 11, 2020 10:56
Date Aggregation #swift #dates
import Cocoa
struct entry {
let date: Date
let vol: Measurement<UnitVolume>
}
let entries = [
@SlappyAUS
SlappyAUS / closures.swift
Created October 19, 2020 00:23
closures #syntax
// Custom closure with escaping
func getSentimentScore(searchTerm: String, scoreCallback: @escaping (_ score: Int) -> Void) {
}
@SlappyAUS
SlappyAUS / podfile_cheatsheet.md
Created October 17, 2020 09:21
Podfile #cheatsheet

Cocoa Pods Cocoapods Basic Cheat Sheet

Create a Podfile at the root of your project

platform :ios, '5.0'

pod 'AFNetworking'
pod 'OHAttributedLabel'
@SlappyAUS
SlappyAUS / cocoa_pods_cheat_sheet.md
Last active October 17, 2020 09:17
Cocoapods Cheat sheet #cheatsheet

Cocoapods-Cheatsheet

Useful commands etc. for Cocoapods

Installation

Command                                          Description
pod init creates a Podfile for the current directory if none currently exists
pod install Downloads all dependencies defined in Podfile and creates an Xcode Pods library project in ./Pods
@SlappyAUS
SlappyAUS / conda_environments.md
Last active October 17, 2020 09:10
Conda Environments #cheatsheet

1. Check conda is installed and in your PATH

Open a terminal client.
Enter conda -V into the terminal command line and press enter.
If conda is installed you should see somehting like the following.\

$ conda -V
conda 3.7.0

2. Check conda is up to date

@SlappyAUS
SlappyAUS / git_cheat_sheet.md
Last active October 17, 2020 09:11
Git Cheat Sheet #cheatsheet

GIT Cheatsheet

git init
git status
git add [filename]			(add to staging area)
git add -A					(add all to staging)
git reset [filename]			(remove from staging)
git commit -m “message”		(commit from staging)
git commit -a -m “message”	(stage and commit)

git clone

@SlappyAUS
SlappyAUS / image_classification_model.swift
Last active October 17, 2020 09:11
Image Classification Model #coreml
import CoreML
import Vision
func detectImage(image: CIImage) {
guard let model = try? VNCoreMLModel(for: FlowerClassifier().model) else {
fatalError("Could not load CoreML model")
}
let request = VNCoreMLRequest(model: model) { (request, err) in
guard let results = request.results as? [VNClassificationObservation] else {