Skip to content

Instantly share code, notes, and snippets.

View hguandl's full-sized avatar

Hao Guan hguandl

View GitHub Profile
@thelastlin
thelastlin / libsk-libfido2_BUILD_FROM_OPENSSH.md
Last active August 24, 2024 11:48
Build libsk-libfido2.so from OpenSSH-portable

Tested on macOS Sonoma Developer beta 2 (23A5276g)

Build libsk-libfido2.so

Prerequisite

  1. Download openssh-portable source code, install libcrypto, libfido2;
  2. Configure openssh-portable build system by ./configure # [options].

Apply patch

@joelekstrom
joelekstrom / SwiftUIDoubleClickModifier.swift
Last active August 28, 2024 09:58
A view modifier that can reliably detect double clicks on macOS, even in List
extension View {
/// Adds a double click handler this view (macOS only)
///
/// Example
/// ```
/// Text("Hello")
/// .onDoubleClick { print("Double click detected") }
/// ```
/// - Parameters:
/// - handler: Block invoked when a double click is detected
@kenji21
kenji21 / xcode-previous-older-sdks.md
Last active October 17, 2024 23:58
Use previous/older SDKs with Xcode
@luncliff
luncliff / test_libdispatch.cpp
Last active January 18, 2024 21:56
C++ 20 Coroutines with libdispatch (Apple platform)
/**
* @author github.com/luncliff ([email protected])
* @brief Personal experiment with libdispatch in Apple platform.
*
* @note clang++ -std=c++2a -stdlib=libc++ -fcoroutines-ts
* @see https://developer.apple.com/library/archive/documentation/General/Conceptual/ConcurrencyProgrammingGuide/Introduction/Introduction.html
* @see https://apple.github.io/swift-corelibs-libdispatch/tutorial/
*/
#define CATCH_CONFIG_RUNNER
#define CATCH_CONFIG_FAST_COMPILE
@mohammadnassiri
mohammadnassiri / numpy_big_sur_issues.md
Last active November 27, 2020 03:20
numpy and its related packages (matplotlib, scipy, pandas, etc) installation problems in MacOS 11 (Big Sur)

If you have issues with installing numpy related packages on Big sur, these steps helped me: 1- Uninstall pyhon installed with homebrew and use python-installer. This resolves numpy issue. And it's better to install 1.18 or just anything bellow 1.19.

brew uninstall python

And install it from: https://www.python.org/downloads/
Then:

pip install numpy==1.18
@dragolabs
dragolabs / ubuntu-vnc-without-monitor.md
Created April 29, 2020 20:09
Run VNC without connected monitor to ubuntu Desktop

Install Video Dummy Package

sudo apt-get install xserver-xorg-video-dummy

Create Default X Windows Configuration File

Create / Edit xorg.conf file Rename file if already exists for backup

@Thomvis
Thomvis / Migrated.swift
Last active October 30, 2024 07:43
An approach towards migrating properties in a Codable struct without having to write a custom Codable implementation
import Cocoa
// Say we have a Person model
enum V1 {
struct Person: Codable {
let name: String
var age: Int
}
}
@domnikl
domnikl / build.gradle.kts
Last active October 11, 2024 11:06
Gradle Kotlin DSL: set main class attribute for jar
tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "com.example.MainKt"
}
}
@matachi
matachi / BytesToTexture.swift
Created November 12, 2018 08:21
Make an image from a byte array in Swift.
class BytesToTexture {
func texture(bytes: [UInt8], bytesPerRow: Int) -> CGImage {
let rgbaData = CFDataCreate(nil, bytes, bytes.count)!
let provider = CGDataProvider(data: rgbaData)!
let colorSpace = CGColorSpaceCreateDeviceRGB()
let bitmapInfo = CGBitmapInfo(rawValue: CGImageAlphaInfo.noneSkipLast.rawValue)
return CGImage(
width: bytesPerRow / 4,
height: bytes.count / bytesPerRow,
bitsPerComponent: 8,

FFmpeg Minimal Build for RTMP Streaming

This tutorial will work you through steps of configuring an FFmpeg build tailored for RTMP streaming on macOS. At first I think of making it support general live streaming, with additional protocols like HLS, but to keep things simple let's stick with RTMP for now. (Anyway, I do include HLS in the protocol list as well as some related bitstream filters but it's untested.)

Goal

The built FFmpeg executable should