Skip to content

Instantly share code, notes, and snippets.

View p-x9's full-sized avatar
🤩

p-x9

🤩
View GitHub Profile
@cheebow
cheebow / chordNotes.swift
Created August 24, 2024 03:55
ChordNotes
import Foundation
let noteToSemitone: [String: Int] = [
"C": 0, "C#": 1, "Db": 1,
"D": 2, "D#": 3, "Eb": 3,
"E": 4, "Fb": 4, "E#": 5,
"F": 5, "F#": 6, "Gb": 6,
"G": 7, "G#": 8, "Ab": 8,
"A": 9, "A#": 10, "Bb": 10,
"B": 11, "Cb": 11, "B#": 0
@leptos-null
leptos-null / swift-hook.md
Last active January 20, 2025 05:49
Hooking Swift functions

This article aims to describe how to hook Swift functions.

Thanks to help from @NightwindDev for discussion and testing.

Overall, the idea is simple: Write our own Swift code that will have the same calling convention as the target code, then get a pointer to our own code and the target code, and call MSHookFunction with these values.

Code

@sidepelican
sidepelican / concat.swift
Last active June 5, 2024 08:27
resultBuilderと雪だるまジェネリクスで型の組み立て
import Foundation
@dynamicMemberLookup
struct Concat<L: Decodable, R: Decodable>: Decodable {
init(left: L, right: R) {
self.left = left
self.right = right
}
private var left: L
private var right: R
@Koshimizu-Takehito
Koshimizu-Takehito / MyFlowLayout.swift
Last active June 3, 2024 04:39
改行を考慮した FlowLayout
import SwiftUI
struct FlowLayoutSampleView: View {
@State var width: CGFloat = 180
let tags: [String] = [
"Objective-C",
"Swift",
// "SwiftSwiftSwiftSwiftSwiftSwiftSwiftSwift",
// "SwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwiftSwift",
@el-hoshino
el-hoshino / AssociativeComparisonPrecedence.swift
Last active February 5, 2024 22:40
AssociativeComparison
precedencegroup AssociativeComparisonPrecedence {
associativity: left
higherThan: ComparisonPrecedence
lowerThan: NilCoalescingPrecedence
}
infix operator <: AssociativeComparisonPrecedence
infix operator <=: AssociativeComparisonPrecedence
public func < <V: Comparable>(lhs: V, rhs: V) -> (Bool, V) {
import SwiftUI
public extension View {
func extend<Content: View>(@ViewBuilder transform: (Self) -> Content) -> some View {
transform(self)
}
func `if`<T: View, F: View>(_ condition: Bool, @ViewBuilder _ then: (Self) -> T, @ViewBuilder `else`: (Self) -> F) -> some View {
condition ? ViewBuilder.buildEither(first: then(self)) : ViewBuilder.buildEither(second: `else`(self))
}
@niaeashes
niaeashes / DebugJsonView.swift
Last active March 15, 2024 05:57
SwiftUI JSON View for Debugging
#if canImport(SwiftUI) && DEBUG
import SwiftUI
struct DebugJsonView: View {
let json: JsonElement
init(_ json: String) {
self.json = JsonElement.parse(json)
@kalupas226
kalupas226 / JapaneseTCA.md
Last active June 19, 2024 05:11
A Japanese translation of The Composable Architecture's README.md

The Composable Architecture

CI Slack

The Composable Architecture (省略すると TCA) は、コンポジション、テスト、開発者にとっての使いやすさを考慮し、一貫性のある理解しやすい方法でアプリケーションを構築するためのライブラリです。SwiftUI、UIKit などで使用することができ、Apple のどのプラットフォーム (iOS, macOS, tvOS, watchOS) でも使用

@greymd
greymd / sudo新一.md
Last active May 15, 2025 06:15
sudo新一

 オレは高校生シェル芸人 sudo 新一。幼馴染で同級生の more 利蘭と遊園地に遊びに行って、黒ずくめの男の怪しげな rm -rf / 現場を目撃した。端末をみるのに夢中になっていた俺は、背後から近づいてきたもう1人の --no-preserve-root オプションに気づかなかった。 俺はその男に毒薬を飲まされ、目が覚めたら・・・ OS のプリインストールから除かれてしまっていた!

sudo がまだ $PATH に残っていると奴らにバレたら、また命を狙われ、他のコマンドにも危害が及ぶ』

 上田博士の助言で正体を隠すことにした俺は、 which に名前を聞かれて、とっさに『gnuplot』と名乗り、奴らの情報をつかむために、父親がシェル芸人をやっている蘭の $HOME に転がり込んだ。ところが、このおっちゃん・・・とんだヘボシェル芸人で、見かねた俺はおっちゃんになりかわり、持ち前の権限昇格能力で、次々と難タスクを解決してきた。おかげで、おっちゃんは今や世間に名を知られた名エンジニア、俺はといえばシェル芸 bot のおもちゃに逆戻り。クラスメートの convertojichattextimg にお絵かきコマンドと誤解され少年ワンライナーお絵かき団を結成させられる始末。

 ではここで、博士が作ってくれたメカを紹介しよう。最初は時計型麻酔 kill 。ふたについた照準器にあわせてエンターを押せば、麻酔シグナルが飛び出し、プロセスを瞬時に sleep させることができる。 次に、蝶ネクタイ型 banner 。裏についているダイヤルを調整すれば、ありとあらゆる大きさのメッセージを標準出力できる。必殺のアイテムなら fork 力増強シューズ。電気と磁力で足を刺激し、 :(){ :|:&amp; };: でプロセステーブ

@infernalheaven
infernalheaven / poc.c
Created September 16, 2021 02:18
macOS 11.5.2/iOS 14.7.1 Kernel Race Condition poc
/*
Written By Pan ZhenPeng(@peterpan980927) of Alibaba Security Pandora Lab
use it on macOS: cc poc.c -o poc while True; do ./poc ; done
*/
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>