Skip to content

Instantly share code, notes, and snippets.

View ncooke3's full-sized avatar

Nick Cooke ncooke3

  • Google
  • Atlanta, GA
View GitHub Profile
@ncooke3
ncooke3 / ClassesAndStructs.swift
Last active July 28, 2019 04:59
Example of key difference between Classes and Structs in Swift
import UIKit
// Key Idea: Classes are Reference types and Structs are Value types!
class Runner {
var type: String
var level: Int
var pro: Bool
@ncooke3
ncooke3 / UnwrappingOptionals.swift
Created July 28, 2019 05:55
Examples of the ways to unwrap optional values
import UIKit
var optionalString: String? // can be i.e "hello" or nil
// method 1️⃣: if let
if let string = optionalString {
print("I have a value. I am \(string)")
} else {
print("I do not have a value yet- I am nil!")
}
@ncooke3
ncooke3 / GraphTraversals.swift
Created August 24, 2019 21:38
Graph Traversal Algorithms in Swift!
/// Playground Demonstrating Common Graph Traversal Algorithms
struct GraphNode: Hashable {
let label: String
//let neighbors: Set<GraphNode>
init(label: String) {
self.label = label
//self.neighbors = Set<GraphNode>()
}
@ncooke3
ncooke3 / pythonalize.py
Last active September 23, 2019 03:40
Simple python script that formats "Hello World" to "hello_world" and copies formatted string to clipboard!
# Hey! This is a script that formats a string to the lowercased, underscore-joined strings frequently used in python.
# On mac, copy this file into your /usr/local/bin directory!
# You can then run it anywhere in terminal with:
# >>> python pythonalize.py "The string you want formatted!"
# The string you pass in will be automatically copied to your Mac's clipboard!
import subprocess
import sys
def convert_to_file_name_syntax(name):
@ncooke3
ncooke3 / fetchData.m
Created February 1, 2020 23:47
Simple Objective-C API Call
- (NSString *)fetchData {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setHTTPMethod:@"GET"];
[request setURL:[NSURL URLWithString:stringURL]];
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData * _Nullable data,
NSURLResponse * _Nullable response,
NSError * _Nullable error) {
NSString *myString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
@ncooke3
ncooke3 / mixed_target_llbuild_nodes.yaml
Created July 18, 2023 00:34
LLBuild Node for Dynamically/Statically Linked Mixed Language SwiftPM Target
# See target definitions here:
# https://github.com/ncooke3/swift-package-manager/blob/nc/support-mixed-targets/Fixtures/MixedTargets/BasicMixedTargets/Package.swift#L13-L22
# Dynamically Linked Mixed Target Node
"C.DynamicallyLinkedBasicMixedTarget-debug.dylib":
tool: shell
inputs: ["/Users/nickcooke/Developer/swift-package-manager/Fixtures/MixedTargets/BasicMixedTargets/.build/arm64-apple-macosx/debug/BasicMixedTarget.build/CarPart.m.o","/Users/nickcooke/Developer/swift-package-manager/Fixtures/MixedTargets/BasicMixedTargets/.build/arm64-apple-macosx/debug/BasicMixedTarget.build/Driver.m.o","/Users/nickcooke/Developer/swift-package-manager/Fixtures/MixedTargets/BasicMixedTargets/.build/arm64-apple-macosx/debug/BasicMixedTarget.build/Engine.swift.o","/Users/nickcooke/Developer/swift-package-manager/Fixtures/MixedTargets/BasicMixedTargets/.build/arm64-apple-macosx/debug/BasicMixedTarget.build/FluxCapacitor.m.o","/Users/nickcooke/Developer/swift-package-manager/Fixtures/MixedTargets/BasicMixedTargets/
@ncooke3
ncooke3 / build.log
Created August 23, 2023 15:51
mixed-target-cxx-interop-build-log-failing
debug: /usr/bin/xcrun --sdk macosx --show-sdk-path
debug: /usr/bin/xcrun --sdk macosx --show-sdk-platform-path
debug: /usr/bin/xcrun --find swiftc
debug: /Applications/Xcode_15-beta-5.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -print-target-info
debug: /usr/bin/xcrun --find libtool
debug: /usr/bin/xcrun vtool -show-build /Users/nickcooke/Library/Developer/Xcode/DerivedData/swift-package-manager-fnxfxyeqhuuelohbuxseapweetoa/Build/Products/Debug/PackageFrameworks/PackageDescription.framework/PackageDescription
debug: /usr/bin/xcrun vtool -show-build /Users/nickcooke/Library/Developer/Xcode/DerivedData/swift-package-manager-fnxfxyeqhuuelohbuxseapweetoa/Build/Products/Debug/PackageFrameworks/PackagePlugin.framework/PackagePlugin
debug: /usr/bin/xcrun --find swift-plugin-server
debug: /usr/bin/xcrun --sdk macosx --find xctest
debug: /Applications/Xcode_15-
@ncooke3
ncooke3 / gist:4ef3bd061b9367c68c9cb925af5fd746
Created March 15, 2024 17:54
App bundle investigation
This file has been truncated, but you can view the full file.
## SPM dependency on binary target
All symbols are statically linked into main app executable (including those from the source dependencies of the xcframework):
<details>
<summary>File tree</summary>
<br>
```
/Users/nickcooke/Library/Developer/Xcode/DerivedData/MyCoolApp-bqbfovegifzmirbdbxmtoafjnnrc/Build/Products/Release-iphoneos/MyCoolApp.app