Skip to content

Instantly share code, notes, and snippets.

View chrispaynter's full-sized avatar
⌨️

Chris Paynter chrispaynter

⌨️
View GitHub Profile
@chrispaynter
chrispaynter / ValueObjectTests.cs
Created April 26, 2022 08:28
Strongly type Value Object
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Test
public abstract class ValueObject<T> where T : ValueObject<T>
{
protected abstract IEnumerable<object> GetEqualityComponents();
@chrispaynter
chrispaynter / CGKeyCode_Extension.swift
Created June 24, 2021 08:09 — forked from chipjarred/CGKeyCode_Extension.swift
Querying macOS if a key is pressed
import CoreGraphics
extension CGKeyCode
{
/*
* From Events.h in Carbon.framework
* Summary:
* Virtual keycodes
*
* Discussion:
@chrispaynter
chrispaynter / AppDelegate.swift
Last active February 25, 2021 15:21
Medium - Simple Swinject boilerplate
import Cocoa
@main
class AppDelegate: NSObject, NSApplicationDelegate {
let appManager = AppManager();
func applicationDidFinishLaunching(_ aNotification: Notification) {
appManager.run()
}
@chrispaynter
chrispaynter / AppDelegate.swift
Last active February 22, 2021 21:54
Medium - Bookmark user chosen directories in macOS sandbox
import Cocoa
import SwiftUI
@main
class AppDelegate: NSObject, NSApplicationDelegate {
var window: NSWindow!
let bookMarkKey = "chosenDirBookmarkKey";
@chrispaynter
chrispaynter / IOServicesTestLaunchAgent.plist
Last active February 17, 2021 19:45
Medium - Daemons and Agents - main.swift
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>IOServicesTestLaunchAgent</string>
<key>Disabled</key>
<false/>
<key>KeepAlive</key>
<dict>
@chrispaynter
chrispaynter / device properties.swift
Created December 29, 2020 20:56 — forked from ArthurYidi/device properties.swift
Get HID Device Properties
let keys = [kIOHIDTransportKey, kIOHIDVendorIDKey, kIOHIDVendorIDSourceKey, kIOHIDProductIDKey, kIOHIDVersionNumberKey, kIOHIDManufacturerKey, kIOHIDProductKey, kIOHIDSerialNumberKey, kIOHIDCountryCodeKey, kIOHIDStandardTypeKey, kIOHIDLocationIDKey, kIOHIDDeviceUsageKey, kIOHIDDeviceUsagePageKey, kIOHIDDeviceUsagePairsKey, kIOHIDPrimaryUsageKey, kIOHIDPrimaryUsagePageKey, kIOHIDMaxInputReportSizeKey, kIOHIDMaxOutputReportSizeKey, kIOHIDMaxFeatureReportSizeKey, kIOHIDReportIntervalKey, kIOHIDSampleIntervalKey, kIOHIDBatchIntervalKey, kIOHIDRequestTimeoutKey, kIOHIDReportDescriptorKey, kIOHIDResetKey, kIOHIDKeyboardLanguageKey, kIOHIDAltHandlerIdKey, kIOHIDBuiltInKey, kIOHIDDisplayIntegratedKey, kIOHIDProductIDMaskKey, kIOHIDProductIDArrayKey, kIOHIDPowerOnDelayNSKey, kIOHIDCategoryKey, kIOHIDMaxResponseLatencyKey, kIOHIDUniqueIDKey, kIOHIDPhysicalDeviceUniqueIDKey]
for key in keys {
if let prop = IOHIDDeviceGetProperty(device, key) {
print("\t" + key + ": \(prop)")
}
}
@chrispaynter
chrispaynter / RecordAudio.swift
Created May 23, 2020 06:49 — forked from hotpaw2/RecordAudio.swift
Swift Audio Recording class. Reads buffers of input samples from the microphone using the iOS RemoteIO Audio Unit API
//
// RecordAudio.swift
//
// This is a Swift class (updated for Swift 5)
// that uses the iOS RemoteIO Audio Unit
// to record audio input samples,
// (should be instantiated as a singleton object.)
//
// Created by Ronald Nicholson on 10/21/16.
// Copyright © 2017,2019 HotPaw Productions. All rights reserved.