Skip to content

Instantly share code, notes, and snippets.

View p-x9's full-sized avatar
🤩

p-x9

🤩
View GitHub Profile
@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 December 13, 2023 06:00
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 June 12, 2024 06:03
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>
@rampadc
rampadc / createSampleBufferFromPixelBuffer.swift
Created February 21, 2021 09:24
Create a CMSampleBuffer from CVPixelBuffer
// Usage
let pixelBuffer: CVImageBuffer? = createPixelBufferFrom(image: image) // see https://gist.github.com/rampadc/10a7dc257552f1fb86c1fcc2d1671bd9
let sampleBuffer: CMSampleBuffer? = createSampleBufferFrom(pixelBuffer: pixelBuffer)
// Function
func createSampleBufferFrom(pixelBuffer: CVPixelBuffer) -> CMSampleBuffer? {
var sampleBuffer: CMSampleBuffer?
var timimgInfo = CMSampleTimingInfo()
var formatDescription: CMFormatDescription? = nil
@lamprosg
lamprosg / Fingerprinting.swift
Last active July 28, 2023 14:03
(iOS) Fingerprinting, identifying a device
//https://nshipster.com/device-identifiers/
//Besides identifierForVendor..
/*
Locale information is the greatest source of identifying information on Apple platforms.
The combination of your preferred languages, region, calendar, time zone,
and which keyboards you have installed say a lot about who you are
especially if you have less conventional preferences.
*/