This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import Dispatch | |
// A simple app to verify https://mastodon.social/@calicoding/112118821467209266 | |
// Allows you to check using Swift Tasks, or Dispatch Queues. | |
// | |
// I found this to not be the case, but maybe this isn't realistic? | |
// When compiled on Xcode 15.3 (either debug or release) and run on iOS 17.4, | |
// background QoS tasks are still executed even when Low Power Mode is enabled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
class FakeCall<T> { | |
private(set) var calls = [T]() | |
func record(_ arguments: T) { | |
calls.append(arguments) | |
} | |
func reset() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIView { | |
func removeAllSubviews() { | |
for view in self.subviews { | |
view.removeFromSuperview() | |
} | |
} | |
@discardableResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Quick and dirty CSV parser I wrote. Handles edge cases badly. Doesn't perform well. Doesn't handle large csv files. | |
// But, hey, it solved my use case! | |
// Swift 4.2+ | |
func parseCSVBadly(csvData: Data) -> [[String]] { | |
guard let csv = String(data: csvData, encoding: .utf8) else { return [] } | |
return csv.components(separatedBy: CharacterSet.newlines).compactMap { line in | |
guard !line.hasPrefix("#") else { return nil } | |
return line.components(separatedBy: ",") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: concourse | |
director_uuid: RESULT OF bosh status --uuid | |
releases: | |
- name: concourse | |
version: latest | |
- name: garden-runc | |
version: latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I spent 2 hours working on this before I gave up. This is what I had when I declared it not worth the effort. | |
import Quick | |
import Nimble | |
import ReactiveCocoa | |
import CarthageKit | |
import OHHTTPStubs | |
class NetworkSpec: QuickSpec { | |
override func spec() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
you$ ./stlparser untitled.stl | |
(triangle 0:) | |
Normal: 0.000000, 0.000000, -1.000000 | |
Vertex 0: 4.341105, 20.788564, 0.000000 | |
Vertex 1: -19.261895, 0.018564, 0.000000 | |
Vertex 2: -19.261895, 20.788564, 0.000000 | |
(triangle 1:) | |
Normal: 0.000000, 0.000000, -1.000000 | |
Vertex 0: -19.261895, 0.018564, 0.000000 | |
Vertex 1: 4.341105, 20.788564, 0.000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
you$ ./stlparser untitled.stl | |
stlparser(71086,0x7fff77ac2310) malloc: *** error for object 0x7fbcd8d007a8: incorrect checksum for freed object - object was probably modified after being freed. | |
*** set a breakpoint in malloc_error_break to debug | |
Abort trap: 6 | |
you$ ./stlparser untitled.stl # no change to the code/binary. | |
<normal output> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python | |
from webhelpers.feedgenerator import Atom1Feed | |
import os | |
import datetime | |
def genPost(webRoot, homeDir): | |
f = open(homeDir + "flightSim/post1.html") | |
idx = f.read() | |
f.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from PIL import Image | |
import math | |
import requests | |
import StringIO | |
def deg2num(lat_deg, lon_deg, zoom): | |
lat_rad = math.radians(lat_deg) | |
n = 2.0 ** zoom |
NewerOlder