Skip to content

Instantly share code, notes, and snippets.

View griffin-stewie's full-sized avatar

griffin-stewie griffin-stewie

View GitHub Profile
@usagimaru
usagimaru / DumpAllMethods.swift
Last active March 28, 2024 19:52
Get all methods of an class or instance in Swift
// Dump all NSApplication’s class methods
let dump = NSApplication.perform(NSSelectorFromString("fp_methodDescription")).takeUnretainedValue() as? String
// Dump all NSApplication’s instance methods
let dump = NSApp.perform(NSSelectorFromString("fp_methodDescription")).takeUnretainedValue() as? String
// or
print(NSApplication.value(forKey: "fp_methodDescription"))
print(NSApp.value(forKey: "fp_methodDescription"))
#include <M5StickC.h>
#include <WiFi.h>
#include <ssl_client.h>
#include <HTTPClient.h>
#define PIN_SW 26
const char* ssid = "ssid";
const char* password = "pass";
const char* WEBHOOK_URL = "url";
@usagimaru
usagimaru / customize_sketch_keyboard_shortcuts.md
Last active August 24, 2023 10:56
Customize Sketch.app’s Open and Save keyboard shortcuts.

Scripts

# Print any keyequivalent definitions
PlistBuddy -c "print NSUserKeyEquivalents" ~/Library/Preferences/com.bohemiancoding.sketch3.plist
# Set keyequivalent of 'Open…' as '^⌘O'
PlistBuddy -c "set NSUserKeyEquivalents:'Open…' '@^o'" ~/Library/Preferences/com.bohemiancoding.sketch3.plist
withAnimation(.bouncy(duration: 0.5, extraBounce: 0.5)) {
isDraggingRight = false
}
@Koshimizu-Takehito
Koshimizu-Takehito / メタボールっぽいやつ2.swift
Created May 7, 2023 03:23
メタボールっぽいやつ2.swift
import SwiftUI
import Combine
extension ParticlesView {
init(count: Int) {
self.init(scales: Array(repeating: false, count: count))
}
}
struct ParticlesView: View {
@chockenberry
chockenberry / ql.sh
Last active March 4, 2024 23:40
QuickLook for macOS shell
#!/bin/sh
# usage:
# ql /tmp/file.jpg
# cat /tmp/file.jpg | ql
# cal -h | ql
if [ -z "$*" ]; then
cat > /tmp/ql.stdin
mime_type=$(file --brief --mime-type /tmp/ql.stdin)
@NSExceptional
NSExceptional / Shell.swift
Created June 25, 2022 23:31
Leverage @dynamicMemberLookup to invoke shell commands dynamically
//
// Shell.swift
//
// Created by Tanner Bennett on 6/25/22.
// Copyright Tanner Bennett (c) 2022
//
import Foundation
extension StringProtocol {
@tarunon
tarunon / TaskContext.swift
Last active September 25, 2021 09:30
Swift Task Extension for slim AsyncSequence access.
import UIKit
class Base: UIViewController {
func mySomeAsyncSequence() -> AsyncStream<String> {
fatalError()
}
func use(_ value: String) {
print(value)
}
@treastrain
treastrain / ConcurrencyNFCApp.swift
Created August 27, 2021 20:45
SwiftUI App + Core NFC + Swift Concurrency を使って書いた、交通系電子マネーカードの残高読み取りサンプル。 https://twitter.com/treastrain/status/1431356306963587072
//
// ConcurrencyNFCApp.swift
// ConcurrencyNFC
//
// Created by treastrain on 2021/08/28.
//
import SwiftUI
import CoreNFC
@jpsim
jpsim / parallel_map.swift
Created June 11, 2021 15:18
Parallel map in Swift
extension Array {
func parallelMap<T>(transform: (Element) -> T) -> [T] {
var result = ContiguousArray<T?>(repeating: nil, count: count)
return result.withUnsafeMutableBufferPointer { buffer in
DispatchQueue.concurrentPerform(iterations: buffer.count) { idx in
buffer[idx] = transform(self[idx])
}
return buffer.map { $0! }
}
}