Skip to content

Instantly share code, notes, and snippets.

View gazolla's full-sized avatar

Sebastiao Gazolla Jr gazolla

View GitHub Profile
@insidegui
insidegui / AccountStatus.swift
Last active July 27, 2018 19:01
Obtaining the user's iCloud account status using CloudKit
CKContainer.default().accountStatus { status, error in
if let error = error {
// some error occurred (probably a failed connection, try again)
} else {
switch status {
case .available:
// the user is logged in
case .noAccount:
// the user is NOT logged in
case .couldNotDetermine:
@alimir1
alimir1 / QuickSortSwift3.swift
Last active December 2, 2017 13:08
Quick Sort in Swift 3
func quickSort<T: Comparable>(array: [T]) -> [T] {
guard !array.isEmpty else { return [] }
let pivot = array.first!
let arrayLessThanOrEqualToPivot = array.dropFirst().filter { $0 <= pivot }
let arrayGreaterThanOrEqualToPivot = array.dropFirst().filter { $0 > pivot }
return quickSort(arrayLessThanOrEqualToPivot) + [Int(pivot)] + quickSort(arrayGreaterThanOrEqualToPivot)
}
@alimir1
alimir1 / checkIfPalindrome.swift
Last active August 2, 2023 19:06
Check if string is palindrome Swift 3
func isPalindrome(_ word: String) -> Bool {
let word = word.lowercased().characters.filter{ $0 != " " }
for (i, character) in word.enumerated() {
if character != word[word.count-i-1] {
return false
}
}
return true
}
@vasanthk
vasanthk / System Design.md
Last active May 28, 2024 20:01
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@uebo
uebo / Default-568h@2x.png
Last active October 12, 2022 01:41
iOS Sample Launch Screen File
Default-568h@2x.png
@josephmosby
josephmosby / gist:4264437
Created December 12, 2012 02:49
Week Two of Ruby on Rails: The Incredible Power of Rails

I have now hit my first "wow" moment with Rails, where I actually understood why it has the following it does. It has raised some questions for me about the pedagogy of Rails, but that is not the language's fault; it is a question for the community.

Rails is fast. Mind-blowingly fast. From my cursory looks at the framework, it is immediately apparent that this was designed from the ground up to give me everything I'm going to inevitably want in a basic web application. And yet, for some reason, it isn't immediately sold that way. It's instead sold with stuff like...

"I'm not even joking when I say this, but I think some of the resources out there make it intentionally hard for non-technical people to start learning."

The above line was from a class on Rails - not a Ruby class, but a Rails class. The class was designed so that you could have no coding experience whatsoever and build an MVP, and it advertises itself as such. I think learning to code, even at the lowest level of difficulty, is a fantast