Skip to content

Instantly share code, notes, and snippets.

View hanrw's full-sized avatar
🎯
Focusing

itshan hanrw

🎯
Focusing
View GitHub Profile
@hanrw
hanrw / SlidingToggleStyle.swift
Created April 6, 2025 08:47
SlidingToggleStyle
import SwiftUI
struct SlidingToggleStyle: ToggleStyle {
var activeColor: Color = .blue.opacity(0.5)
func makeBody(configuration: Configuration) -> some View {
HStack {
configuration.label
Spacer()
@hanrw
hanrw / GenericPickerView.swift
Created March 17, 2025 04:09
GenericPickerView
// Copyright © 2025 onegai.com. All rights reserved.
import SwiftUI
struct GenericPickerView<T: CaseIterable & RawRepresentable>: View where T.RawValue == String, T: Hashable {
@Binding var selection: T
private let labelImageName: String
private let localizedString: (T) -> String
func mosaicRectangles(in image: UIImage, from quadrilaterals: [QuadrilateralBox]) -> [QuadrilateralBox: UIImage] {
var resultMap: [QuadrilateralBox: UIImage] = [:]
guard var ciImage = CIImage(image: image) else {
print("Couldn't create CIImage.")
return resultMap
}
// Correct the orientation because `CIImage.init` can lose it
@hanrw
hanrw / fast_speech_text_speech.py
Created February 15, 2024 16:20 — forked from thomwolf/fast_speech_text_speech.py
speech to text to speech
""" To use: install LLM studio (or Ollama), clone OpenVoice, run this script in the OpenVoice directory
git clone https://github.com/myshell-ai/OpenVoice
cd OpenVoice
git clone https://huggingface.co/myshell-ai/OpenVoice
cp -r OpenVoice/* .
pip install whisper pynput pyaudio
"""
from openai import OpenAI
import time
@hanrw
hanrw / VirtualKeyboard.swift
Created January 31, 2024 12:37 — forked from ethanhuang13/VirtualKeyboard.swift
MacBook Air M1 Zhuyin Keyboard written with SwiftUI ~=300 LOC, < 4hrs
//
// VirtualKeyboard.swift
// MacBook Air M1 Zhuyin Keyboard
// Written with SwiftUI ~=300 LOC, < 4hrs
// Created by Ethan Huang on 2021/1/13.
// Twitter: @ethanhuang13
import SwiftUI
struct VirtualKeyboard: View {
import SwiftUI
struct RefreshControl: View {
var coordinateSpace: CoordinateSpace
var onRefresh: ()->Void
@State var refresh: Bool = false
var body: some View {
GeometryReader { geo in
if (geo.frame(in: coordinateSpace).midY > 50) {
Spacer()
@hanrw
hanrw / WeatherView.swift
Created November 7, 2023 14:09 — forked from unixzii/WeatherView.swift
A demo of implementing iOS Weather card in SwiftUI.
import SwiftUI
struct HeaderView: View {
var body: some View {
HStack {
Image(systemName: "info.circle.fill")
.resizable()
.frame(width: 12, height: 12)
Text("Section Header")
.font(.system(size: 13))
import Foundation
import SwiftUI
// MARK: - Custom Button Style
struct MobileMeButtonStyle: ButtonStyle {
// MARK: Metrics
@ScaledMetric private var cornerRadius = 12
@ScaledMetric private var horizontalLabelPadding = 12
@ScaledMetric private var verticalLabelPadding = 8
@hanrw
hanrw / synoinfo.conf
Last active June 30, 2023 14:47
Synology DS918+ Enable extra lan ports
This only verified for reinstall -
- Jun's Loader 1.04b
- DSM_DS918+_24922.pat 6.2.2
===== check current maxlanport =====
user@DiskStation:/etc.defaults$ cat synoinfo.conf|grep maxlan
maxlanport="2"
=====modify synoinfo.conf =====
user@DiskStation:/etc.defaults$ sudo vi synoinfo.conf
@hanrw
hanrw / semantic-commit-messages.md
Created November 25, 2022 07:32 — forked from joshbuchea/semantic-commit-messages.md
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example