Skip to content

Instantly share code, notes, and snippets.

View ryohey's full-sized avatar
👶

ryohey ryohey

👶
View GitHub Profile
@ryohey
ryohey / gist:2147c8f3effdb2c6b67d96d239bfad3b
Created March 15, 2024 04:22
Survey: Time stretch on JavaScript
https://github.com/0xfe/vexwarp
ステレオ: 対応
アルゴリズム: Phase Vocoder
音質: あまりよくない
AudioBufferを出力するので使いやすそう。めちゃくちゃ古い
https://github.com/olvb/phaze
ステレオ: 対応
アルゴリズム: Phase Vocoder
音質: あまりよくない
import SwiftUI
import UIKit
/// UIKit でジェスチャを取得するための透明な View
///
/// overlay で利用する
/// 参考 https://stackoverflow.com/a/57943387/1567777
struct ClearLongPressGestureView: UIViewRepresentable {
let onChanged: (Bool) -> Void
import SwiftUI
extension View {
/// By reducing the hit detection, make it so that tap detection occurs within the range of the frame
///
/// In SwiftUI, a View within about 10pt radius from the tap position is detected as touch,
/// so we place a contentShape that is just as small.
func exactHitArea() -> some View {
modifier(ExactHitAreaModifier())
}
@ryohey
ryohey / View+TapExact.swift
Created July 21, 2023 05:23
SwiftUI Custom Extension: Precise onTapGesture. This extension to SwiftUI's onTapGesture method addresses the default behavior where the tap recognition area slightly extends beyond the View's actual drawn bounds. With this extension, taps are accurately recognized only within the exact bounds of the View, ensuring more precise user interaction.
import SwiftUI
extension View {
/**
* This is a custom extension to SwiftUI's onTapGesture, designed to avoid the issue where the tappable area extends slightly beyond the view's drawing bounds.
* Unlike the original onTapGesture, this version ensures the tap is only recognized within the exact drawing bounds of the View.
*/
func onTapGestureExact(_ action: @escaping (CGPoint) -> Void) -> some View {
overlay {
GeometryReader { proxy in
@ryohey
ryohey / redraw.swift
Created February 10, 2023 00:59
SwiftUI redraw test
import SwiftUI
struct ContentView: View {
@State private var count = 0
@State private var states: [InfoView.State] = [.init(text: "", text2: "", text3: "")]
var body: some View {
VStack {
RedrawBorder {
Button {
@ryohey
ryohey / naming-swiftgen-localizable-strings.md
Created September 30, 2022 05:20
SwiftGen 向け Localizable.strings のキー名の命名規則

ローカライズ

Localizable.strings を更新します。

キー

SwiftGen を使ってコード生成しているので、キーは CamelCase で適当な粒度で . で区切ってグルーピングします。

画面名.要素 または 画面名.要素.状態 となるようにしてください。

@ryohey
ryohey / gist:80ef8897c0506fc82d612b7659d732be
Created June 4, 2021 01:49
アクセスガイドを解除
パスコードロックしてない iPad がアクセスガイドのパスコードがわからなくなり解除できなくなった
再現するかわからないが、下記の手順でなぜかアクセスガイドが解除できた
- ホームボタン+電源ボタン同時押しで強制再起動
- ロック画面出てる状態でホームボタン+電源ボタン同時押しで強制再起動
- ロック画面をスワイプでカメラを起動
- 左下のサムネイルからカメラロールを開く
- すべての写真を選択
@ryohey
ryohey / !README.md
Last active June 30, 2022 02:10
macOS を初期化したらやること

Apps

  • Xcode
  • Spark
  • BetterSnapTool

CLI

# Install Homebrew

Don't

function onTapButton(type) {
  switch (type) {
    case "foo":
      fuga()
      break
    case "bar":
 hoge()
@ryohey
ryohey / recursiveRelimport.js
Last active October 28, 2020 15:16
convert absolute import to relative
const fs = require("fs")
const child_process = require("child_process")
const readdirRecursively = (dir, files = []) => {
const paths = fs.readdirSync(dir)
const dirs = []
for (const path of paths) {
const stats = fs.statSync(`${dir}/${path}`)
if (stats.isDirectory()) {
dirs.push(`${dir}/${path}`)