Skip to content

Instantly share code, notes, and snippets.

View mikehouse's full-sized avatar

Mikhail Demidov mikehouse

  • Cyprus
View GitHub Profile
@mikehouse
mikehouse / runCommand.swift
Created May 5, 2024 12:51 — forked from dduan/runCommand.swift
How to fork()+execv() in Swift
import Foundation
func withCStrings(_ strings: [String], scoped: ([UnsafeMutablePointer<CChar>?]) throws -> Void) rethrows {
let cStrings = strings.map { strdup($0) }
try scoped(cStrings + [nil])
cStrings.forEach { free($0) }
}
enum RunCommandError: Error {
case WaitPIDError
@mikehouse
mikehouse / View+Debug.swift
Last active October 3, 2023 08:54
SwiftUI View Debug Tracking
extension View {
public func debugView<T: View>(_ type: T.Type, file: String = #filePath, line: UInt = #line) -> some View {
#if DEBUG
return background(DebugView(type: type, file: file, line: line))
#else
return self
#endif
}
}
@mikehouse
mikehouse / How_to_pair_apple_tv_to_mac.txt
Last active December 21, 2022 15:48
How to pair Apple TV to MacOS via WiFi
1. Make sure Mac and Apple TV have the same network ("AirPlay and HomeKit", "Allow Access" is set to "Anyone in the Same Network")
2. In Xcode open "Devices & Simulators" window
3. On Apple TV open "Remote App And Device" -> "Remote App And Device"
4. Click "pair" and enter code
5. If "pair" reapear again then turn off the wifi on your Mac for 10 seconds and then turn it on again (https://developer.apple.com/forums/thread/108459)
6. Maybe needed to delete the TV from ingored list https://stackoverflow.com/a/63195311/3614746
#import <UIKit/UIKit.h>
@interface ApplicationDelegateProxyType ()
@property (nonnull, nonatomic) NSArray<id <UIApplicationDelegate>> *objects;
@end
@implementation ApplicationDelegateProxyType
require 'webrick'
require 'webrick/https'
require 'openssl'
require 'json'
# curl https://localhost:port/test (pass '-k' to accept self signed certificate)
# openssl req -x509 -newkey rsa:4096 -keyout priv.pem -out cert.pem -days 365 -nodes
# cert = OpenSSL::X509::Certificate.new File.read 'cert.pem'
# pkey = OpenSSL::PKey::RSA.new File.read 'priv.pem'