Skip to content

Instantly share code, notes, and snippets.

View eneko's full-sized avatar
💻

Eneko Alonso eneko

💻
View GitHub Profile
@eneko
eneko / xcodeclean.sh
Created July 19, 2016 00:04
xcodeclean
alias xcodeclean='rm -frd ~/Library/Developer/Xcode/DerivedData/* && rm -frd ~/Library/Caches/com.apple.dt.Xcode/*'
@eneko
eneko / instabug.md
Last active May 18, 2017 18:25
Instabug -> GitHub Integration issue
$ whois google.com
Whois Server Version 2.0
Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.
GOOGLE.COM.ACKNOWLEDGES.NON-FREE.COM.NAMESILO.COM
GOOGLE.COM.AFRICANBATS.ORG
@eneko
eneko / Output
Created January 2, 2018 19:59
Swift 4 Dispatch on Linux
$ swift run
Hello, world!
Bye!
@eneko
eneko / List.swift
Last active July 29, 2018 12:21
Linked List in Swift
/// A list is either empty or it is composed of a first element (head)
/// and a tail, which is a list itself.
///
/// See http://www.enekoalonso.com/projects/99-swift-problems/#linked-lists
class List<T> {
var value: T
var nextItem: List<T>?
convenience init?(_ values: T...) {
self.init(Array(values))
@eneko
eneko / retain_cycles.swift
Last active February 8, 2019 17:56
Function references and retain cycles
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 / isEmoji.swift
Created July 23, 2019 23:56
Determine if a Character is an emoji, in 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 / iPad-releases.md
Last active May 19, 2020 14:33
List of iPad releases

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 / gp.fish
Created May 19, 2020 17:46
Fish function to pull latest code from remote and remove merged local branches
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 / ArrayProduct.swift
Last active June 3, 2020 21:53
Cartesian product of arrays
// 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"])