Skip to content

Instantly share code, notes, and snippets.

View multitudes's full-sized avatar
🎯
Focusing

laurent b multitudes

🎯
Focusing
View GitHub Profile
@multitudes
multitudes / locale.c
Created May 4, 2024 07:48
extended ascii and display locale
#include <locale.h>
#include <wchar.h>
#include <stdio.h>
int main() {
// Set the locale to the user's default locale
setlocale(LC_ALL, "");
// wchat_t is a wide character type
wchar_t c1 = L'ò';
@multitudes
multitudes / helloworld.s
Last active May 2, 2024 17:09
helloworld.s
/*
minimul required to print hello world.
also can compile with
cc helloworld.s
and exec with ./a.out
or use the linking
as helloworld.s -o helloworld.o
ld helloworld.o -o helloworld -l System -syslibroot `xcrun -sdk macosx --show-sdk-path` -e _main -arch arm64
*/
@multitudes
multitudes / ctest.c
Last active May 1, 2024 09:40
little endianness revealed!
long long y = 0xaabbccddeeff0123LL;
/*
compile the above with cc -c ctest.c
and open your binary editor. in VIM open the object file with
vim -b ctest.o
then :%! xxd
and look for the line with your variable
This is how it looks like on my mac m1
@multitudes
multitudes / FB10144005.md
Created August 12, 2023 08:56 — forked from mbrandonw/FB10144005.md
iOS 16 Navigation API feedbacks

How to execute logic when NavigationLink is tapped?

FB10144005

Currently it doesn't seem possible to execute additional logic when a navigation link is tapped with the new NavigationLink(value:) initializer. When the link is tapped it updates path state all the way back at the root NavigationStack to drive navigation, but there are many times where we need to perform logic after the tap and before the drill down.

For example, after tapping a link we may want to pre-emptively load some data to show on the drill down screen. Or we may want to perform some form validation. Or we may want to track some analytics. This does not seem possible with the current link API.

A workaround is to use Buttons instead of NavigationLinks, but then you lose all of the styling and affordances given to links, such as chevrons when used in List.

If the API for NavigationLink cannot be changed to accomodate for this, perhaps a new ButtonStyle could be introduced that allows regular buttons to take on the sty

@multitudes
multitudes / AudioPlayerView.swift
Last active June 28, 2023 03:04
Audio Player written for SwiftUI - first pass
//
// AudioPlayerView.swift
// AccessibleAudioPlayer
//
// Created by Laurent B on 30/10/2021.
//
import SwiftUI
import AVKit
@multitudes
multitudes / UserDefault.swift
Created May 1, 2021 12:43 — forked from simonbs/UserDefault.swift
Property wrapper that stores values in UserDefaults and works with SwiftUI and Combine.
/**
* I needed a property wrapper that fulfilled the following four requirements:
*
* 1. Values are stored in UserDefaults.
* 2. Properties using the property wrapper can be used with SwiftUI.
* 3. The property wrapper exposes a Publisher to be used with Combine.
* 4. The publisher is only called when the value is updated and not
* when_any_ value stored in UserDefaults is updated.
*
* First I tried using SwiftUI's builtin @AppStorage property wrapper
import Foundation
enum TargetEnum: Codable {
case first(SomeObject)
case second(OtherObject)
enum CodingKeys: CodingKey {
case type
}
@multitudes
multitudes / ioslocaleidentifiers.csv
Created October 9, 2020 14:12 — forked from jacobbubu/ioslocaleidentifiers.csv
iOS Locale Identifiers
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
mr Marathi
bs Bosnian
ee_TG Ewe (Togo)
ms Malay
kam_KE Kamba (Kenya)
mt Maltese
ha Hausa
es_HN Spanish (Honduras)
ml_IN Malayalam (India)
ro_MD Romanian (Moldova)
@multitudes
multitudes / Best in Class iOS Checklist
Created July 9, 2020 09:35 — forked from DreamingInBinary/Best in Class iOS Checklist
This is a public checklist updated every year after the latest version of iOS and iPadOS are shipped. It's a boiled down version of a "Best in Class" app checklist created by Jordan Morgan.
# A Best in Class Checklist
A boiled down checklist adapted from this [post](https://www.swiftjectivec.com/a-best-in-class-app/), created by @jordanmorgan10.
> To use this, create a Github Issue in your own repo, and simply copy and paste this text.
## iOS Core Technology
_Things any iOS app can benefit from_
- [ ] iCloud Sync
- [ ] [Core Spotlight integration](https://github.com/DreamingInBinary/Spend-Stack/issues/120)
@multitudes
multitudes / Constants.swift
Created May 14, 2020 11:20
DeviceType and ScreenSize for iPhone's
enum ScreenSize {
static let width = UIScreen.main.bounds.size.width
static let height = UIScreen.main.bounds.size.height
static let maxLength = max(ScreenSize.width, ScreenSize.height)
static let minLength = min(ScreenSize.width, ScreenSize.height)
}
enum DeviceType {
static let idiom = UIDevice.current.userInterfaceIdiom
static let nativeScale = UIScreen.main.nativeScale