Skip to content

Instantly share code, notes, and snippets.

View multitudes's full-sized avatar
🎯
Focusing

laurent b multitudes

🎯
Focusing
View GitHub Profile

Keybase proof

I hereby claim:

  • I am multitudes on github.
  • I am multitudes (https://keybase.io/multitudes) on keybase.
  • I have a public key ASDRExgTkkwQv_1nAcGkgh7T58lKw6DHI56bxc0eyHAJ9go

To claim this, I am signing this object:

@multitudes
multitudes / euler4.js
Last active May 3, 2020 14:55
Project Euler challenge number 4 - my solution in javascript
// Project Euler: Problem 4: Largest palindrome product
//A palindromic number reads the same both ways.
// The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
// Find the largest palindrome made from the product of two n-digit numbers.
function largestPalindromeProduct(n) {
let largest = 0
let inputString = "9".repeat(n)
let inputNumber = +inputString
@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
@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 / 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)
import Foundation
enum TargetEnum: Codable {
case first(SomeObject)
case second(OtherObject)
enum CodingKeys: CodingKey {
case type
}
@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
@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 / 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 / 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