Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

André J eonist

🎯
Focusing
View GitHub Profile
View Tailwind colors
.text-transparent color: transparent; Aa
.text-current color: currentColor; Aa
.text-black color: #000; Aa
.text-white color: #fff; Aa
.text-gray-100 color: #f7fafc; Aa
.text-gray-200 color: #edf2f7; Aa
.text-gray-300 color: #e2e8f0; Aa
.text-gray-400 color: #cbd5e0; Aa
.text-gray-500 color: #a0aec0; Aa
.text-gray-600 color: #718096; Aa
View gist:40d8c7f36e948e26b550441d5ccbfbef
Pink
#ff2d55
Purple
#5856d6
Orange
#ff9500
Yellow
@eonist
eonist / hamburger-menu.html
Created Oct 23, 2020
hamburger menu (uses only css)
View hamburger-menu.html
<!DOCTYPE html>
<html>
<head>
<title>Hamburger menu prototype</title>
<meta charset="UTF-8" />
<link rel="stylesheet" href="styles.css">
<meta name="viewport" content="width=device-width">
</head>
<body>
<div class="header">
View hasNil (operate on optional array)
/**
* Asserter
*/
extension Array {
/**
* Asserts if array has nil values
* ## Examples:
* let someArr: [Int?] = [1,2,nil]
* someArr.hasNil() // true
* [1,2,2].hasNil() // false
View CheapFlights (Mobility challenge)
# CheapFlights (Mobility challenge)
- Use api's from top 3 flight aggregators (use google to find them) 💻
- Searchbar with: input destination and departure, input time 🗺
- Get cheapest tickets (direct flight only) ✈️
- Present with basic info in table view 📝
- Present detail view if item is pressed 👇
- Pull table to refresh (or refresh button if web-app) ⬇️
## Challenges:
@eonist
eonist / UITableView+Extension.swift
Created May 2, 2020
UITableView+Extension.swift
View UITableView+Extension.swift
import UIKit
extension UITableViewDataSource where Self: UITableView {
/**
* Returns a cells in table
* - Note: Unlike native cell(for index) or visibleCells calls, this call wont break/complain even when called before the cells are available
*/
var availableCells: [UITableViewCell] {
self.subviews.compactMap { $0 as? UITableViewCell }
}
View gist:9bf74542b9ffc6e98d6e9321fb9ae262
extension UIViewController {
/**
* Traverses the entire VC hirearchy downwards and collects VC'w that are of speccific PARAM: type
* - Fixme: ⚠️️ this can be written more elegantly with flatMap
* ## Example:
* let vc: CustomVC? = UIApplication.shared.delegate?.window?.rootViewController?.descendants().first
*/
func descendants<T>(type: T.Type? = nil) -> [T] {
var childrenOfType: [T] = []
self.children.forEach {
@eonist
eonist / Payroll.swift
Last active Dec 23, 2019
Xmas challenge
View Payroll.swift
struct Employee {
let name: String
let sallary: Double
let role: Role
enum Role: String {
case it, hr, managment
}
}
func payMonthly(employees: [Employee]) {
employees.forEach { payMonthly(employee: $0) }
@eonist
eonist / QRVersionTableTest.swift
Created Dec 12, 2019
a small method to convert qrversion table to a more machine readable format
View QRVersionTableTest.swift
import Foundation
final class QRVersionTableTest {}
extension QRVersionTableTest {
/**
* convertQRVersionTable
* - Note: a small method to convert qrversion table to a more machine readable format
*/
static func convertQRVersionTable() {
Swift.print("convertQRVersionTable")
View VerticalAlignedLabel.swift
import UIKit
/**
* Example:
* let label: VerticalAlignedLabel = UILabel()
* label.contentMode = .bottom
* Ref: https://stackoverflow.com/questions/18247934/how-to-align-uilabel-text-from-bottom
* TODO: ⚠️️ Maybe we could just do sizeThatFits fitToSize etc or just us TextField?
* Todo: this is cool but its not precise enough. this is more precise: https://stackoverflow.com/a/51761518
* let size = text.size(withAttributes:[.font: UIFont.systemFont(ofSize:18.0)])
*/