Skip to content

Instantly share code, notes, and snippets.

View noppefoxwolf's full-sized avatar
🦊
きつねかわいい!!!

noppe noppefoxwolf

🦊
きつねかわいい!!!
View GitHub Profile
class ViewController: UIViewController {
static let dispatchQueue = DispatchQueue(label: "test")
override func viewDidLoad() {
super.viewDidLoad()
ViewController.dispatchQueue.async {
Thread.current.name = "test thread"
print("done")
}
}
struct State {
var title: String
init(hash: Int) {
// speacialTextが二箇所で使われてしまい、改修時に漏れそう
// またreducer以外の場所でロジックが実行されているので気持ち悪い
title = specialText(hash: hash)
}
}
import SwiftUI
struct ContentView: View {
@ObservedObject var vm: VM = .init()
var body: some View {
NavigationView {
List(vm.items, rowContent: { (item) in
NavigationLink(
destination: DestinationView(vm: vm),
@noppefoxwolf
noppefoxwolf / project.yml
Created October 22, 2020 16:48
project.yml
name: Broadcast
configs:
Debug: debug
Release: release
targetTemplates:
Project:
platform: iOS
deploymentTarget: "14.0"
settings:
base:
@noppefoxwolf
noppefoxwolf / gist:77ab570018beee87efc03084b019313b
Created October 12, 2020 17:03
draw to CALayer directory.
import UIKit
import AVFoundation
class ViewController: UIViewController, AVCaptureVideoDataOutputSampleBufferDelegate {
lazy var session: AVCaptureSession = .init()
lazy var input: AVCaptureDeviceInput = try! AVCaptureDeviceInput(device: device)
lazy var device: AVCaptureDevice = AVCaptureDevice.default(for: .video)!
lazy var output: AVCaptureVideoDataOutput = .init()
override func viewDidLoad() {
using (var blendShapes = subsystem.GetBlendShapeCoefficients(face.trackableId, Allocator.Temp)) {
foreach (var blendShape in blendShapes) {
var location = blendShape.blendShapeLocation.ToString();
var key = new BlendShapeKey(location);
blendShapeProxy.AccumulateValue(key, blendShape.coefficient);
}
}
extension Result {
init(_ successValue: Success?, _ failureValue: Failure?) {
if let failureValue = failureValue {
self = .failure(failureValue)
} else if let successValue = successValue {
self = .success(successValue)
} else {
preconditionFailure()
}
}
@noppefoxwolf
noppefoxwolf / ViewController.swift
Created June 22, 2020 22:58
VNDetectHumanHandPoseRequest
import UIKit
import AVFoundation
import Vision
class ViewController: UIViewController {
lazy var device = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front)!
lazy var input = try! AVCaptureDeviceInput(device: device)
lazy var output = AVCaptureVideoDataOutput()
lazy var session = AVCaptureSession()
class Unity: UnityFrameworkListener {
static let shared = Unity()
private let unityFramework: UnityFramework
var view: UIView { unityFramework.appController()!.window }
override init() {
let frameworkPath = Bundle.main.bundlePath.appending("/Frameworks/UnityFramework.framework")
let bundle = Bundle(path: frameworkPath)!
unityFramework = bundle.principalClass!.getInstance()
super.init()
```main.swift
import Foundation
print("a".appending("b"))
```
```
$ swift main.swift
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret main.swift -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name main