Skip to content

Instantly share code, notes, and snippets.

View NunoAlexandre's full-sized avatar

Nuno NunoAlexandre

View GitHub Profile
/// This module contains useful extensions to the base
/// navigation controllers in respect to managing orientation,
/// as well as adding missing functionality to the sdk types.
import Foundation
func currentOrientation() -> UIInterfaceOrientation {
return UIApplication.shared.statusBarOrientation
}
=> ERROR [9/9] RUN brownie compile 29.1s
------
> [9/9] RUN brownie compile:
#13 1.187 Brownie v1.16.4 - Python development framework for Ethereum
#13 1.187
13.5kiB [00:00, 632kiB/s]
#13 1.458 Downloading from https://solc-bin.ethereum.org/linux-amd64/solc-linux-amd64-v0.8.7+commit.e28d00a7
100%|██████████| 12.1M/12.1M [00:21<00:00, 558kiB/s]
#13 23.33 qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory
#13 23.41 Downloading from https://solc-bin.ethereum.org/linux-amd64/solc-linux-amd64-v0.8.9+commit.e5eed63a

Open

@NunoAlexandre
NunoAlexandre / easier-github.css
Created September 9, 2020 18:58
Easier Github on the eyes
.xHeader-item--full {
width: 2;
width: auto !important;
margin: 0 auto !important;
flex: none;
}
xbody,.Box {
background-color: #e7e7e7;
}
observers.append(
NotificationCenter.default.addObserver(
forName: AVAudioSession.interruptionNotification,
object: nil,
queue: nil
)
{ [weak weakSelf = self] (notification) in
weakSelf?.onInterruption(notification)
}
)
@NunoAlexandre
NunoAlexandre / small-step-before.swift
Created July 17, 2019 11:08
A small step - before
observers.append(NotificationCenter.default.addObserver(forName: AVAudioSession.interruptionNotification, object: nil, queue: nil) { [weak weakSelf = self] (notification) in
weakSelf?.onInterruption(notification)
})
@NunoAlexandre
NunoAlexandre / User+FromJson.swift
Created March 25, 2019 19:30
Making User FromJson compliant
extension User: FromJson {
static func from(value: JsonValue) -> User? {
return value.ifObject { json in
User(
id: try json .! "id",
name: try json .! "name",
email: json .? "email",
country: json .? "country",
subscription: try json .! "subscription",
favouriteSongs: (json ..? "favouriteSongs") ?? []
@NunoAlexandre
NunoAlexandre / storkExampleTypes.swift
Created March 25, 2019 19:26
Stork Example Types
struct User {
let id: Int
let name: String
let email: String?
let country: Country?
let subscription: Subscription
let favouriteSongs: [Song]
}
enum Subscription: String {
@discardableResult
func attemptDownload(forItem item: Item) -> Promise<URL> {
if !canSubmitDownload(forItem: item) {
return Promise.reject(DownloadError.duplicatedDownload)
}
else if !SettingsManager.shared.canDownloadOrStream() {
let error = DownloadError.canNotUseInternet
self.registerFailedDownload(item, withError: error)
return Promise.reject(error)
}
@NunoAlexandre
NunoAlexandre / downloadBefore.swift
Created March 23, 2019 19:19
A callback hell downloading an item
@discardableResult
func downloadSpecificActivity(activityInfo: SpecificActivityFirebase, completion: @escaping ((URL?, Error?) -> Void), progress: ((Double?) -> Void)? = nil) -> ContentDownload? {
if SettingsManager.shared.wifiOnlyEnabled && SettingsManager.shared.reachabilityManager?.isReachableOnWWAN ?? false {
completion(nil, ContentError.notAllowedOnWWanError)
} else if SettingsManager.shared.reachabilityManager != nil && !SettingsManager.shared.reachabilityManager!.isReachable {
completion(nil, ContentError.notConnected)
} else {
let downloadStartDate = Date.now()
if let tempUrl = temporaryDownloadUrl(forSpecificActivity: activityInfo) {