Skip to content

Instantly share code, notes, and snippets.

View wildthink's full-sized avatar

Jason Jobe wildthink

  • 08:23 (UTC -05:00)
View GitHub Profile
@helje5
helje5 / servedocc.swift
Last active July 16, 2022 22:24
Small Swift Script to serve `.doccarchive`s to the browser
#!/usr/bin/swift sh
import MacroExpress // @Macro-swift
// MARK: - Parse Commandline Arguments & Usage
func usage() {
let tool = path.basename(process.argv.first ?? "servedocc")
print(
"""
@yogurtsake
yogurtsake / MultipeerHandler.swift
Created March 14, 2020 23:54
Post for StackOverflow
protocol AudioStreamingDelegate {
func connectedDevicesChanged(manager: MultipeerHandler, connectedDevices: [String])
}
class MultipeerHandler: NSObject {
private let peerType = "stream-audio"
private var peerId: MCPeerID!
private var serviceAdvertiser: MCNearbyServiceAdvertiser?
private var serviceBrowser: MCNearbyServiceBrowser?
@quangDecember
quangDecember / build-xcframework.sh
Last active February 19, 2024 10:05
Build XCFramework (universal) framework, create new Aggregate target, add to New Run Script Phase
env > env.txt
instruments -s devices > devices.txt
#! /bin/sh -e
# This script demonstrates archive and create action on frameworks and libraries
# Based on script by @author Boris Bielik
# Release dir path
OUTPUT_DIR_PATH="${PROJECT_DIR}/XCFramework"
function archivePathSimulator {
@sukov
sukov / CodableExtension.swift
Last active September 19, 2024 11:27 — forked from mikebuss/decode-json-swift.swift
Codable (Encode & Decode) [Any] and [String: Any] Swift 5
// Original: https://gist.github.com/loudmouth/332e8d89d8de2c1eaf81875cfcd22e24
import Foundation
private struct JSONCodingKeys: CodingKey {
var stringValue: String
init(stringValue: String) {
self.stringValue = stringValue
}
@unnamedd
unnamedd / MacEditorTextView.swift
Last active May 26, 2024 17:49
[SwiftUI] MacEditorTextView - A simple and small NSTextView wrapped by SwiftUI.
/**
* MacEditorTextView
* Copyright (c) Thiago Holanda 2020-2021
* https://twitter.com/tholanda
*
* MIT license
*/
import Combine
import SwiftUI
import Foundation
infix operator <>: AdditionPrecedence
public protocol Semigroup {
func combine(with other: Self) -> Self
static func <> (lhs: Self, rhs: Self) -> Self
}
@theisegeberg
theisegeberg / MCSessionAdapter.swift
Last active December 29, 2021 17:00
MultiPeerConnectivity example (tested working in iOS 12, device + simulator)
import Foundation
import MultipeerConnectivity
class MCSessionAdapter:NSObject,MCSessionDelegate {
var session:MCSession?
weak var delegate:PeerSessionDelegate?
func setSession(_ session:MCSession) {
self.session = session
@IanKeen
IanKeen / Decodable+Random.swift
Last active March 29, 2022 13:06
Custom Decoder that can be used to create Decodable instances that are populated with random values
import Foundation
extension Decodable {
public static func randomInstance() throws -> Self {
let decoder = RandomDecoder()
return try Self(from: decoder)
}
}
private class RandomDecoder: Decoder {
@swalkinshaw
swalkinshaw / tutorial.md
Last active November 13, 2023 08:40
Designing a GraphQL API
@kendricktan
kendricktan / capsule_networks.py
Last active August 17, 2021 17:12
Clean Code for Capsule Networks
"""
Dynamic Routing Between Capsules
https://arxiv.org/abs/1710.09829
"""
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torchvision.transforms as transforms