Skip to content

Instantly share code, notes, and snippets.

View Tomn94's full-sized avatar
๐Ÿ’ผ
Working

Thomas Naudet Tomn94

๐Ÿ’ผ
Working
View GitHub Profile
@cellularmitosis
cellularmitosis / EmojiPointersDemo.swift
Created August 15, 2018 18:11
Representing pointer values as emoji can be useful for "visually" debugging certain issues, like cell reuse, etc.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
@BZHugs
BZHugs / README.md
Last active June 12, 2018 13:55
Example of code optimisation (remove libc)
root@laptop [02:00:10] [~/Documents/pentest/cours] 
-> # ls -alh opti printf-libc
-rwxr-xr-x 1 root root 1,5K juin  12 14:00 opti
-rwxr-xr-x 1 root root 726K juin  12 14:00 printf-libc

root@laptop [02:00:26] [~/Documents/pentest/cours] 
-> # ./opti arg1 arg2 arg3    
./opti
arg1
@tclementdev
tclementdev / libdispatch-efficiency-tips.md
Last active June 3, 2025 21:56
Making efficient use of the libdispatch (GCD)

libdispatch efficiency tips

The libdispatch is one of the most misused API due to the way it was presented to us when it was introduced and for many years after that, and due to the confusing documentation and API. This page is a compilation of important things to know if you're going to use this library. Many references are available at the end of this document pointing to comments from Apple's very own libdispatch maintainer (Pierre Habouzit).

My take-aways are:

  • You should create very few, long-lived, well-defined queues. These queues should be seen as execution contexts in your program (gui, background work, ...) that benefit from executing in parallel. An important thing to note is that if these queues are all active at once, you will get as many threads running. In most apps, you probably do not need to create more than 3 or 4 queues.

  • Go serial first, and as you find performance bottle necks, measure why, and if concurrency helps, apply with care, always validating under system pressure. Reuse

#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@zats
zats / FindReplace.json
Last active May 5, 2025 17:54
Alternative spellings for some emojis according to /System/Library/PrivateFrameworks/CoreEmoji.framework/Versions/A/Resources/en.lproj/FindReplace.strings
{
"๐Ÿ’":"diamond | engagement ring | diamond ring | diamond rings | diamonds | engagement rings",
"๐Ÿ†Ž":"blood type AB",
"โฃ":"heart",
"๐Ÿ‡ฑ๐Ÿ‡จ":"Saint Lucia | Saint Lucian flag",
"๐Ÿ‡ฎ๐Ÿ‡ช":"Ireland | Irish flag",
"๐Ÿ‡จ๐Ÿ‡ฎ":"Cรดte dโ€™Ivoire | Ivory Coast | Ivorian flag",
"๐Ÿ’Ž":"diamond | gem | gemstone | jewel | diamonds | gems | gemstones | jewels",
"โ˜ ๏ธ":"skull and crossbones | poison | poisonous",
"๐Ÿ‘ฉโ€๐Ÿ’ป":"technology worker | tech worker | technologist | techie | IT worker | Apple genius | woman in technology | woman tech worker | woman technologist | woman IT worker | woman in IT | woman Apple genius",
@smileyborg
smileyborg / InteractiveTransitionCollectionViewDeselection.m
Last active November 3, 2024 16:25
Animate table & collection view deselection alongside interactive transition (for iOS 11 and later)
// UICollectionView Objective-C example
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] firstObject];
if (selectedIndexPath != nil) {
id<UIViewControllerTransitionCoordinator> coordinator = self.transitionCoordinator;
if (coordinator != nil) {
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {
@zats
zats / emojis.swift
Created September 17, 2017 18:24
All emojis available in iOS 11.0 including lookup categories for gender and skin-tone dependent
let emojis: [String: [String]] = [
// +[EMFEmojiCategory TravelAndPlacesEmoji]
"travel": ["๐Ÿš—", "๐Ÿš•", "๐Ÿš™", "๐ŸšŒ", "๐ŸšŽ", "๐ŸŽ", "๐Ÿš“", "๐Ÿš‘", "๐Ÿš’", "๐Ÿš", "๐Ÿšš", "๐Ÿš›", "๐Ÿšœ", "๐Ÿ›ด", "๐Ÿšฒ", "๐Ÿ›ต", "๐Ÿ", "๐Ÿšจ", "๐Ÿš”", "๐Ÿš", "๐Ÿš˜", "๐Ÿš–", "๐Ÿšก", "๐Ÿš ", "๐ŸšŸ", "๐Ÿšƒ", "๐Ÿš‹", "๐Ÿšž", "๐Ÿš", "๐Ÿš„", "๐Ÿš…", "๐Ÿšˆ", "๐Ÿš‚", "๐Ÿš†", "๐Ÿš‡", "๐ŸšŠ", "๐Ÿš‰", "๐Ÿš", "๐Ÿ›ฉ", "โœˆ๏ธ", "๐Ÿ›ซ", "๐Ÿ›ฌ", "๐Ÿš€", "๐Ÿ›ฐ", "๐Ÿ’บ", "๐Ÿ›ถ", "โ›ต๏ธ", "๐Ÿ›ฅ", "๐Ÿšค", "๐Ÿ›ณ", "โ›ด", "๐Ÿšข", "โš“๏ธ", "๐Ÿšง", "โ›ฝ๏ธ", "๐Ÿš", "๐Ÿšฆ", "๐Ÿšฅ", "๐Ÿ—บ", "๐Ÿ—ฟ", "๐Ÿ—ฝ", "โ›ฒ๏ธ", "๐Ÿ—ผ", "๐Ÿฐ", "๐Ÿฏ", "๐ŸŸ", "๐ŸŽก", "๐ŸŽข", "๐ŸŽ ", "โ›ฑ", "๐Ÿ–", "๐Ÿ", "โ›ฐ", "๐Ÿ”", "๐Ÿ—ป", "๐ŸŒ‹", "๐Ÿœ", "๐Ÿ•", "โ›บ๏ธ", "๐Ÿ›ค", "๐Ÿ›ฃ", "๐Ÿ—", "๐Ÿญ", "๐Ÿ ", "๐Ÿก", "๐Ÿ˜", "๐Ÿš", "๐Ÿข", "๐Ÿฌ", "๐Ÿฃ", "๐Ÿค", "๐Ÿฅ", "๐Ÿฆ", "๐Ÿจ", "๐Ÿช", "๐Ÿซ", "๐Ÿฉ", "๐Ÿ’’", "๐Ÿ›", "โ›ช๏ธ", "๐Ÿ•Œ", "๐Ÿ•", "๐Ÿ•‹", "โ›ฉ", "๐Ÿ—พ", "๐ŸŽ‘", "๐Ÿž", "๐ŸŒ…", "๐ŸŒ„", "๐ŸŒ ", "๐ŸŽ‡", "๐ŸŽ†", "๐ŸŒ‡", "๐ŸŒ†", "๐Ÿ™", "๐ŸŒƒ", "๐ŸŒŒ", "๐ŸŒ‰", "๐ŸŒ"],
// +[EMFEmojiCategory NatureEmoji]
"nature": ["๐Ÿถ", "๐Ÿฑ", "๐Ÿญ", "๐Ÿน", "๐Ÿฐ", "๐ŸฆŠ", "๐Ÿป", "๐Ÿผ", "๐Ÿจ", "๐Ÿฏ", "๐Ÿฆ", "๐Ÿฎ", "๐Ÿท", "๐Ÿฝ", "๐Ÿธ", "๐Ÿต", "๐Ÿ™ˆ", "๐Ÿ™‰", "๐Ÿ™Š", "๐Ÿ’", "๐Ÿ”", "๐Ÿง", "๐Ÿฆ", "๐Ÿค", "๐Ÿฃ", "๐Ÿฅ", "๐Ÿฆ†", "๐Ÿฆ…", "๐Ÿฆ‰", "๐Ÿฆ‡", "๐Ÿบ", "๐Ÿ—", "๐Ÿด", "๐Ÿฆ„", "๐Ÿ", "๐Ÿ›", "๐Ÿฆ‹", "๐ŸŒ", "๐Ÿš", "๐Ÿž", "๐Ÿœ", "๐Ÿ•ท", "๐Ÿ•ธ", "๐Ÿข", "๐Ÿ", "๐ŸฆŽ", "๐Ÿฆ‚", "๐Ÿฆ€", "๐Ÿฆ‘", "๐Ÿ™", "๐Ÿฆ", "๐Ÿ ", "๐ŸŸ", "๐Ÿก", "๐Ÿฌ", "๐Ÿฆˆ
// Swift's untyped errors are a goddam PiTA. Here's the pattern I use to try to work around this.
// The goal is basically to try to guarantee that every throwing function in the app throws an
// ApplicationError instead of some unknown error type. We can't actually enforce this statically
// But by following this convention we can simplify error handling
enum ApplicationError: Error, CustomStringConvertible {
// These are application-specific errors that may need special treatment
case specificError1
case specificError2(SomeType)
@lattner
lattner / TaskConcurrencyManifesto.md
Last active June 3, 2025 20:55
Swift Concurrency Manifesto
@radianttap
radianttap / wwdc17.sh
Created June 7, 2017 09:57
Bash script to download all HD videos + PDF slides for WWDC 2017
#!/bin/bash
#Setup the environnement
mkdir wwdc2017
cd wwdc2017
mkdir tmp_download
cd tmp_download
#Extract IDs
echo "Downloading the index"