Skip to content

Instantly share code, notes, and snippets.

View JuniperPhoton's full-sized avatar

JuniperPhoton JuniperPhoton

View GitHub Profile
@JuniperPhoton
JuniperPhoton / observations.swift
Last active July 26, 2025 08:48
Observations for Pre-iOS 26
// NOTE: Though this works on my demo, be cautious when using this in production.
/// Provides a way to observe value changes in a closure using ``AsyncSequence``,
/// just like the [Observations](https://developer.apple.com/documentation/observation/observations) introduced in iOS 26 lineup.
///
/// - Parameters:
/// - action: A closure that returns a value to observe. It must read one or more values in an object with `@Observable` macro.
/// - Returns: An `AsyncSequence` that yields the value returned by the action closure when it changes.
@available(iOS 17.0, macOS 14.0, *)
func observations<V>(
@JuniperPhoton
JuniperPhoton / FloatingOverlayApp.swift
Last active March 31, 2025 08:47
A simple application to show a black, resizable, title-less, always-on-top NSWindow on Mac.
//
// FloatingOverlayApp.swift
// FloatingOverlay
//
// Created by JuniperPhoton on 2025/3/12.
//
import SwiftUI
// Dependency: https://github.com/sindresorhus/KeyboardShortcuts
@JuniperPhoton
JuniperPhoton / RGBToXYZMatrix.swift
Created December 10, 2024 08:37
Calculate the matrix for the linear RGB to CIE XYZ transformation.
/// Calculate the matrix for the linear RGB to CIE XYZ transformation.
///
/// Example code to calcualte the matrix for sRGB:
///
/// ```swift
/// let d65WhitePoint = [0.9505, 1.0, 1.0891]
///
/// matrix = calculateLinearRGBToCIEXYZMatrix(xr: 0.64, yr: 0.33,
/// xg: 0.30, yg: 0.60,
/// xb: 0.1558, yb: 0.06,
@JuniperPhoton
JuniperPhoton / hprof_conv.cs
Created July 11, 2019 11:55
Convert Android hprof to Java SE hprof
using System;
using System.Diagnostics;
using System.IO;
namespace AdbTest {
class Program {
static void Main (string[] args) {
if (args.Length == 0) {
Console.WriteLine ("Please specified folder path");
Environment.Exit (-1);