Skip to content

Instantly share code, notes, and snippets.

Woohoooo 12k on SO!

Andrew Zheng aheze

Woohoooo 12k on SO!
View GitHub Profile
dmr121 / PomodoroPicker.swift
Last active Jan 17, 2022
SwiftUI - Snapping horizontal scrolling pomodoro picker
View PomodoroPicker.swift
// PomodoroPicker.swift
// pomodoro
// Created by David Rozmajzl on 1/1/22.
import SwiftUI
struct PomodoroPicker<Content, Item: Hashable>: View where Content: View {
BrentMifsud / PreviewDevice+Devices.swift
Last active Nov 30, 2021
Extension on PreviewDevice that includes all available devices
View PreviewDevice+Devices.swift
import SwiftUI
/// Static properties for all preview devices.
/// Usage:
/// ```swift
/// struct TestView_Previews: PreviewProvider {
/// static var previews: some View {
/// Group {
View MatrixDigitalRain.swift
// Author: SwiftUI-Lab (
// Description: This code is part of the "Advanced SwiftUI Animations - Part 5"
// Article:
import SwiftUI
struct ContentView: View {
var body: some View {
View gist:35c31a29e7f9eebdccfdc7cdfe9fe724
else if type == NSFetchedResultsChangeType.move {
// A hackish way to ensure PIN icon is updated.
if let newIndexPath = newIndexPath, let indexPath = indexPath {
if let plainNote = nsPlainNoteProvider.getNSPlainNote(newIndexPath), let noteCell = collectionView.cellForItem(at: indexPath) as? NoteCell {
selected: false,
animate: false

Breaking Changes of 2.0

These are the breaking changes of version 2.0.

"Breaking change" includes:

  • [R]emoval: a feature is removed.
  • [N]ame changes: a feature is renamed.
  • [B]ehavior: something does not behave the way they did in 1.x.
  • [T]yping: types of arguments, attributes or return values changes in an incompatible way. (e.g. None disallowed for argument)
  • [S]yntax: a syntax previously allowed for an operation is no longer allowed. (e.g. positional only arguments, new required arguments)
View gist:b32fd2d321c18818037a62e06b1bbab9
// Good
@IBAction func sideMenuClicked(_ sender: UIBarButtonItem) {
statusBarHidden = true
self.navigationController? = 20
UIView.animate(withDuration: Constants.config_shortAnimTime) { () -> Void in
simonbs / childForStatusBarStyle.swift
Last active Dec 28, 2021
It seems that -childForStatusBarStyle: isn’t called on a UIViewController that is presented from a SwiftUI view using UIViewControllerRepresentable. Or am I doing something wrong? I came up with this *ugly* workaround that swizzles -childForStatusBarStyle: to return an associated object when present and uses the default implementation as fallback.
View childForStatusBarStyle.swift
// We'll store a UIViewController as an associated object and don't want to store a strong reference to it.
private final class WeakBoxedValue<T: AnyObject>: NSObject {
private(set) weak var value: T?
init(_ value: T?) {
self.value = value
// Use associated objects to a UIViewController that should determine the status bar appearance.
View Jumping view with anchors, alignmentGuides and preferenceKeys
// TransactionView.swift
// Created by Balazs Erdesz on 2021. 02. 23..
import SwiftUI
import Combine
struct TransactionView: View {

Minecraft on Apple Silicon

In this gist, you can find the steps to run Minecraft 1.16.4 natively on Apple Silicon (AS), without needing Rosetta 2 translation of the dependencies (mainly LWJGL and related libraries).

While it's possible to use a launcher like MultiMC to have a prettier way to run the game on AS, it requires installing even more dependencies (like QT) which take time and are difficult to distribute. Therefore, I've put together a command line-based launcher tool using a couple shell & Python scripts.

To get up and running quickly, follow the steps below. Otherwise, for more detail, watch my YouTube video.

Download my package

aheze / DocumentPicker.swift
Last active Aug 6, 2021
UIDocumentPickerViewController example in Swift 5. Bug fixed version of this article:
View DocumentPicker.swift
// DocumentPicker.swift
import UIKit
import MobileCoreServices
protocol DocumentDelegate: class {
func didPickDocument(document: Document?)