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
音質: あまりよくない
@ryohey
ryohey / convert.js
Created May 23, 2017 04:13
Convert YUV420(I420) Progressive Planar to RGB in JavaScript
const WIDTH = 176
const HEIGHT = 144
const progRGB = yuv420ProgPlanarToRgb(base64ToArrayBuffer(yuv420ProgPlanarImage()), WIDTH, HEIGHT)
const canvas = document.createElement("canvas")
document.body.appendChild(canvas)
const ctx = canvas.getContext("2d")
const imageData = ctx.createImageData(WIDTH, HEIGHT)
putRGBToRGBA(imageData.data, progRGB, WIDTH, HEIGHT)
ctx.putImageData(imageData, 0, 0)
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 / !README.md
Last active June 30, 2022 02:10
macOS を初期化したらやること

Apps

  • Xcode
  • Spark
  • BetterSnapTool

CLI

# Install Homebrew
@ryohey
ryohey / gist:80ef8897c0506fc82d612b7659d732be
Created June 4, 2021 01:49
アクセスガイドを解除
パスコードロックしてない iPad がアクセスガイドのパスコードがわからなくなり解除できなくなった
再現するかわからないが、下記の手順でなぜかアクセスガイドが解除できた
- ホームボタン+電源ボタン同時押しで強制再起動
- ロック画面出てる状態でホームボタン+電源ボタン同時押しで強制再起動
- ロック画面をスワイプでカメラを起動
- 左下のサムネイルからカメラロールを開く
- すべての写真を選択
@ryohey
ryohey / detach.js
Last active March 11, 2021 21:16
Detach and flatten all frames in Figma
const detachAndFlatten = (pageName) => {
const detach = (c) => figma.union([c], c.parent)
const page = figma.root.children.find(c => c.name === pageName)
const frames = page.children.filter(c => c.type === "FRAME")
for (let frame of frames) {
for (let c of frame.children) {
if (c.type === "INSTANCE") {
c = detach(c)
} else {