Skip to content

Instantly share code, notes, and snippets.

extension StringProtocol {
/// str[NSRange(location:0, length: 9)]
subscript(_ range: NSRange) -> SubSequence {
guard let stringRange = Range<String.Index>(range, in: self) else {
fatalError("String index is out of range")
}
return self[stringRange]
}
@veekaybee
veekaybee / normcore-llm.md
Last active December 26, 2024 06:23
Normcore LLM Reads

Anti-hype LLM reading list

Goals: Add links that are reasonable and good explanations of how stuff works. No hype and no vendor content if possible. Practical first-hand accounts of models in prod eagerly sought.

Foundational Concepts

Screenshot 2023-12-18 at 10 40 27 PM

Pre-Transformer Models

@iOSappssolutions
iOSappssolutions / FB11835461.md
Last active May 12, 2023 13:44
NavigationStack creates memory leak if Hashable referrence type is used for path

FB11835461

In real world applications it makes more sense to use ObservableObject referrence type to drive navigation than simple value type. The example below demonstrates that.

Problem is that for some reason NavigationStack will create memory leak if path is set to empty array after navigating any number of times through stack. All view models that were created in process will be retained in memory even though path is set to [].

Same problem occurs if we set path to empty array and just swap whole NavigationStack with any other view still all objects created will be retained in memory.

There is workaround that I will show bellow to fix this but it is still very buggy behaviour IMO.

@CodaFi
CodaFi / IP.swift
Last active June 3, 2023 05:32
An async sequence of kevents
#if canImport(Darwin)
import Darwin
#elseif canImport(Glibc)
import Glibc
#else
#error("unsupported platform")
#endif
/// Core utilities for interacting with IP-based abstractions.
public struct IP {
@BadPirate
BadPirate / README.md
Created January 28, 2020 19:22
A utility class for capturing iOS App Will Suspend, and App Did Un-suspend events

Summary

iOS doesn't report when an app will be suspended (placed from background into a non-processing state) nor does it seem to fire a notification once the app has resumed. There is some confusion about this as there is a notification when the app becomes "active" or will resign the "active" state, however this is not always the right value needed. iOS Apps have a number of states:

  1. Active: App is in the foreground (frontmost) and there are no notifications or menu's pulled over it. Pulling a menu down or getting an external notification or text message will cause the app to "resign" active, and resume active once the alert has been dealt with.
  2. Background: App is not in the foreground but still processing. This happens briefly before suspend if there are no background tasks running, or can be a permanent state if there is a long running background mode (audio, location, etc) running.
@jamesmontemagno
jamesmontemagno / live-streaming-kit.md
Last active June 25, 2024 06:51
Live Streaming Kit

Here is my live stream setup kit :)

If you are doing a personal stream, I recommend only streaming to a single service such as Twitch. It is better for community building and easier on the streamer. Additionally, if you become an affiliate you are locked into a platform anyways.

How my setup works is that I have my main Desktop PC that has my streaming software, chat, alerts, music, and such all running on it. I have a second surface book that has HDMI out into the capture card in my Desktop PC. I do this because often when you compile apps it may freeze up your computer and stream :(. I have 2 sets of keyboards and mice and 2 monitors that I work off of. This works for me, but you do you :)

Software:

  • OBS: Your main go to for streaming software. It works on every OS :). If you want something with everything baked in take a look at Streamlabs OBS.
  • Streamlabs has all of your pop ups for subscribers and such on t
import Darwin.C
import Venice
struct SubProcess {
let path: String
let arguments: [String]
func run(sync sync: Bool = true) -> Int? {
@joeduffy
joeduffy / teariface.go
Created July 18, 2015 15:40
Breaking Go memory safety by violating concurrency safety (#2: interfaces).
// teariface.go
// A simple demonstration of breaking Go memory safety by violating concurrency
// safety. We alias an interface variable which is of course multiple words;
// the net result is the itable pointer and target object pointer end up
// mismatched, triggering undefined behavior (wrong results, AVs, etc).
package main
import (
"fmt"
"runtime"
@joeduffy
joeduffy / tear.go
Created July 17, 2015 22:24
Breaking Go memory safety by violating concurrency safety.
// tear.go
// A simple demonstration of breaking Go memory safety by violating concurrency
// safety. We alias a shared slice variable -- which is a multi-word variable --
// and then reads/write that shared variable in parallel between Goroutines.
// If "torn slice: ..." is printed, something VeryBad(tm) has occurred...
package main
import (
"fmt"
"runtime"
@praeclarum
praeclarum / EasyLayout.fs
Last active August 23, 2020 09:52
EasyLayout makes writing auto layout code in Xamarin.iOS F# easier.
module EasyLayout
open System
open System.Drawing
open Microsoft.FSharp.Quotations
open Microsoft.FSharp.Quotations.Patterns
open Microsoft.FSharp.Quotations.DerivedPatterns
open MonoTouch.Foundation
open MonoTouch.UIKit