Skip to content

Instantly share code, notes, and snippets.

View NunoAlexandre's full-sized avatar

Nuno NunoAlexandre

View GitHub Profile
@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) {
@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 / 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 {
@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 / 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)
})
observers.append(
NotificationCenter.default.addObserver(
forName: AVAudioSession.interruptionNotification,
object: nil,
queue: nil
)
{ [weak weakSelf = self] (notification) in
weakSelf?.onInterruption(notification)
}
)
@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;
}

Open

=> 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
λ kubectl logs -f centrifugechainvalidator-0-7df4d577dd-jzhsh -n altair-dev-rococo
2022-04-25 08:30:17.463 INFO main sc_cli::runner: Centrifuge Parachain Collator
2022-04-25 08:30:17.463 INFO main sc_cli::runner: ✌️ version 0.10.11-aa467c6-x86_64-linux-gnu
2022-04-25 08:30:17.463 INFO main sc_cli::runner: ❤️ by Centrifuge <admin@centrifuge.io>, 2017-2022
2022-04-25 08:30:17.463 INFO main sc_cli::runner: 📋 Chain specification: Altair Dev
2022-04-25 08:30:17.463 INFO main sc_cli::runner: 🏷 Node name: altair-dev-rococo-collator-0
2022-04-25 08:30:17.463 INFO main sc_cli::runner: 👤 Role: AUTHORITY
2022-04-25 08:30:17.463 INFO main sc_cli::runner: 💾 Database: RocksDb at /data/chains/altair_dev/db/full
2022-04-25 08:30:17.463 INFO main sc_cli::runner: ⛓ Native runtime: altair-1012 (altair-1.tx1.au1)
2022-04-25 08:30:17.528 INFO main pallet_collator_selection::pallet: assembling new collators for new session 0 at #0