Skip to content

Instantly share code, notes, and snippets.

View rijieli's full-sized avatar

Roger Lee rijieli

View GitHub Profile
@rijieli
rijieli / HelloAnimation.swift
Created February 24, 2024 09:14 — forked from amosgyamfi/HelloAnimation.swift
HelloAnimation.swift
//
// HelloAnimation.swift
// OpenvisionOS
//
// Created by Amos Gyamfi on 17.2.2024.
//
import SwiftUI
struct HelloAnimation: View {
@rijieli
rijieli / gist:58abc113d032bd48ddd815b65d853582
Last active February 16, 2024 15:55 — forked from bakertim/gist:68a4c5778fb561ea34a4
Set iOS Build Number to Git Commit Count
# source http://blog.jaredsinclair.com/post/97193356620/the-best-of-all-possible-xcode-automated-build
#
# Set the build number to the current git commit count.
# If we're using the Dev scheme, then we'll suffix the build
# number with the current branch name, to make collisions
# far less likely across feature branches.
# Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/
#
git=`sh /etc/profile; which git`
@rijieli
rijieli / whenHovered.md
Created February 15, 2024 09:19 — forked from importRyan/whenHovered.md
Reliable SwiftUI mouse hover

Reliable mouseEnter/Exit for SwiftUI

Kapture 2021-03-01 at 14 43 39

On Mac, SwiftUI's .onHover closure is not always called on mouse exit, particularly with high cursor velocity. A grid of targets or with finer target shapes will often have multiple targets falsely active after the mouse has moved on.

It is easy to run back to AppKit's safety. Below is a SwiftUI-like modifier for reliable mouse-tracking. You can easily adapt it for other mouse tracking needs.

import SwiftUI
@rijieli
rijieli / AVSpeechSynthesisVoiceTest.swift
Created November 17, 2023 09:53
Test the built-in voice speech on iOS
let allVoices = AVSpeechSynthesisVoice.speechVoices().filter { theVoice in
theVoice.language.contains("zh")
}
for idx in allVoices.indices {
let theVoice = allVoices[idx]
let lang = theVoice.language
let gender: String
if theVoice.gender == .male {
gender = "male"
@rijieli
rijieli / InfiniteScrollChart.swift
Created November 7, 2022 08:44 — forked from beader/InfiniteScrollChart.swift
Infinite Scrollable Bar Chart using Swift Charts
//
// InfiniteScrollChart.swift
// ChartsGallery
//
// Created by beader on 2022/11/3.
//
import SwiftUI
import Charts
@rijieli
rijieli / ChineseTransliterator.swift
Created May 20, 2022 03:09
Transliterate Chinese between simplified and traditional (the wrong way).
import UIKit
struct ChineseTransliterator {
static func transliterate(text: String, sourceView: UIView) {
let textView = UITextView()
textView.isHidden = true
textView.text = text
textView.selectAll(nil)
sourceView.addSubview(textView)
@rijieli
rijieli / MusicPlayerManager.swift
Created May 12, 2022 16:38 — forked from loretoparisi/MusicPlayerManager.swift
Ambiguous use of play of MPMusicPlayerController in iOS11, swift4 - Apple Example "Adding Content to Apple Music"
/*
See LICENSE folder for this sample’s licensing information.
Abstract:
The `MusicPlayerManager` manages the media playback using the `MPMusicPlayerController` APIs.
*/
import UIKit
import MediaPlayer
# TAGS speparated by vertical line |
OPTIMIZE_TAGS="OPTIMIZE:|TEST:"
find "${SRCROOT}/" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($OPTIMIZE_TAGS).*\$" | wc -l | xargs -I{} echo "warning: 🔆 {} Optimize | Test Items"
NEXTUP_TAGS="NEXTUP:"
find "${SRCROOT}/" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($NEXTUP_TAGS).*\$" | wc -l | xargs -I{} echo "warning: 🗃️ {} NextUp Tasks"
FIXME_TAGS="FIXME:"
@rijieli
rijieli / Jekyll Local Environment.md
Created March 31, 2022 05:10
Jekyll Running Locally on M1 Chip Mac
brew install rbenv ruby-build
rbenv init # Or add eval "$(rbenv init - zsh)" to rc file
rbenv install 2.7.2
echo 2.7.2 > .ruby-version
gem inst ffi -- --disable-system-libffi
bundle install
bundle exec jekyll serve
@import Photos;
[PHPhotoLibrary requestAuthorizationForAccessLevel:PHAccessLevelReadWrite handler:^(PHAuthorizationStatus status) {
NSLog(@"PHAuthorizationStatus: %ld", status);
PHFetchOptions *fetchOptions = [[PHFetchOptions alloc] init];
fetchOptions.includeHiddenAssets = YES;
fetchOptions.includeAllBurstAssets = YES;
PHFetchResult<PHAsset *> *result = [PHAsset fetchAssetsWithOptions:fetchOptions];