Skip to content

Instantly share code, notes, and snippets.

Avatar
💻

Eneko Alonso eneko

💻
View GitHub Profile
@eneko
eneko / dealloc-breakpoint.md
Last active Jun 17, 2020
Xcode UIViewController dealloc breakpoint
View dealloc-breakpoint.md

Xcode deinit breakpoint for UIViewController

This breakpoint provides an easy way to track view controller deinitialization (deallocation) in UIKit-based applications. This can help finding memory leaks caused by retain cycles preventing view controllers from being deinitialized when dismissed or popped.

From Cédric Luthi's tweet in 2017:

Useful Xcode breakpoint. When you dismiss a controller and you don’t hear the pop sound (or see the log), you probably have a retain cycle.

@eneko
eneko / IndirectProposal.md
Last active Jun 15, 2020
Proposal for 'indirect' modifier keyword for struct properties
View IndirectProposal.md

Proposal for indirect modifier for struct properties

Introduction

Add support for indirect modifier keyword for struct properties

@eneko
eneko / ArrayProduct.swift
Last active Jun 3, 2020
Cartesian product of arrays
View ArrayProduct.swift
// Cartesian product of two arrays
func * <U, V>(lhs: [U], rhs: [V]) -> [(U, V)] {
lhs.flatMap { left in
rhs.map { right in
(left, right)
}
}
}
print([1, 2, 3] * ["a", "b"])
@eneko
eneko / gp.fish
Created May 19, 2020
Fish function to pull latest code from remote and remove merged local branches
View gp.fish
function gp
echo "Pulling latest code..."
git pull
git pull --tags -f
echo "\nDeleting local branches that were removed in remote..."
git fetch -p
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
echo "\nRemaining local branches:"
git branch -vv
end
@eneko
eneko / iPad-releases.md
Last active May 19, 2020
List of iPad releases
View iPad-releases.md

iPad (all)

  • 2010 - iPad
  • 2011 - iPad 2
  • 2012 - iPad (3rd generation)
  • 2012 - iPad Mini
  • 2012 - iPad (4th generation)
  • 2013 - iPad Air
  • 2013 - iPad Mini 2
  • 2014 - iPad Mini 3
  • 2014 - iPad Air 2
@eneko
eneko / iPhone-releases.md
Last active Oct 8, 2020
List of iPhone releases
View iPhone-releases.md

iPhone line

  • 2007 - iPhone
  • 2008 - iPhone 3G
  • 2009 - iPhone 3GS
  • 2010 - iPhone 4 (new design)
  • 2011 - iPhone 4s
  • 2012 - iPhone 5 (new design)
  • 2013 - iPhone 5s and iPhone 5c
  • 2014 - iPhone 6 and iPhone 6 Plus (new design)
  • 2015 - iPhone 6s and iPhone 6s Plus
@eneko
eneko / isEmoji.swift
Created Jul 23, 2019
Determine if a Character is an emoji, in Swift
View isEmoji.swift
extension Character {
var isEmoji: Bool {
return Character(UnicodeScalar(UInt32(0x1d000))!) <= self && self <= Character(UnicodeScalar(UInt32(0x1f77f))!)
|| Character(UnicodeScalar(UInt32(0x2100))!) <= self && self <= Character(UnicodeScalar(UInt32(0x26ff))!)
}
}
@eneko
eneko / retain_cycles.swift
Last active Feb 8, 2019
Function references and retain cycles
View retain_cycles.swift
class MyClass {
var foo: () -> Void = {}
init() {
foo = defaultFoo
}
private func defaultFoo() {
print("Foo Bar")
}
deinit {
print("MyClass Released 🎉") // Never gets called, retain cycle
@eneko
eneko / list-of-curl-options.txt
Last active Jun 14, 2021
List of `curl` options
View list-of-curl-options.txt
$ curl --help
Usage: curl [options...] <url>
--abstract-unix-socket <path> Connect via abstract Unix domain socket
--alt-svc <file name> Enable alt-svc with this cache file
--anyauth Pick any authentication method
-a, --append Append to target file when uploading
--basic Use HTTP Basic Authentication
--cacert <file> CA certificate to verify peer against
--capath <dir> CA directory to verify peer against
-E, --cert <certificate[:password]> Client certificate file and password
@eneko
eneko / Output
Created Jan 2, 2018
Swift 4 Dispatch on Linux
View Output
$ swift run
Hello, world!
Bye!