Skip to content

Instantly share code, notes, and snippets.

View eneko's full-sized avatar
💻

Eneko Alonso eneko

💻
View GitHub Profile
@eneko
eneko / gist:77153be33607e23cc6984e8af5bb46b0
Created September 30, 2016 21:34
Final run of vapor swift install script
$ curl -sL swift.vapor.sh/ubuntu | bash
Swift 3 Quick Installer
🖥 Operating System: ubuntu1404
📦 Installing Dependencies
🔒 Sudo required
Ign http://eu-west-1.ec2.archive.ubuntu.com trusty InRelease
Hit http://eu-west-1.ec2.archive.ubuntu.com trusty-updates InRelease
Hit http://eu-west-1.ec2.archive.ubuntu.com trusty-backports InRelease
Hit http://eu-west-1.ec2.archive.ubuntu.com trusty Release.gpg
Hit http://eu-west-1.ec2.archive.ubuntu.com trusty Release
@eneko
eneko / cache.swift
Created October 25, 2016 03:13
Basic cache, failing on Ubuntu 14.04 with Swift 3.0
import Foundation
fileprivate class CachedItem<T> {
let value: T
fileprivate init(value: T) {
self.value = value
}
}
@eneko
eneko / ergast-indices.sql
Last active November 30, 2016 06:17
Ergast MySQL indices
-- Constructor Standings
alter table constructorstandings add index (constructorid);
alter table constructorstandings add index (raceid);
alter table constructorstandings add unique index constructorrace (constructorid, raceid);
-- Drivers
alter table drivers add unique index driverref (driverref);
-- Driver Standings
alter table driverstandings add index (driverid);
@eneko
eneko / git-purge
Last active June 28, 2023 03:48
`git purge` command to delete local branches that have been deleted on remote
#!/usr/bin/env sh
set -e
echo "Pulling latest code..."
git pull
echo "Deleting local branches that were removed in remote..."
git fetch -p
git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
echo "Remaining local branches:"
git branch -vv
@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-of-curl-options.txt
Last active April 25, 2024 12:21
List of `curl` options
$ 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 / 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))!)
}
}