Skip to content

Instantly share code, notes, and snippets.

@fitsyu
fitsyu / Protokol Kesehatan.swift
Created Jul 6, 2021
Protokol kesehatan menggunakan bahasa pemrograman Swift
View Protokol Kesehatan.swift
protocol Kesehatan {
func memakaiMasker()
func mencuciTangan()
func menjagaJarak()
func menjauhiKerumunan()
func membatasiMobilisasi()
}
@fitsyu
fitsyu / G29-mac.js
Created Mar 3, 2021
Make use of Logitech G29 steering wheel to press commonly used buttons on a Mac
View G29-mac.js
const g29 = require('logitech-g29')
const robot = require('robotjs')
g29.on('shifter-gear', function(gear) {
switch (gear) {
case 0:
break;
case 1:
robot.keyTap('v', ['command']);
break;
@fitsyu
fitsyu / prokes.swift
Last active Dec 24, 2020
Implementasi Protokol Kesehatan Menggunakan Swift
View prokes.swift
protocol Kesehatan {
func memakaiMasker()
func menjagaJarak()
func mencuciTangan()
}
class MauSehat: /* implements */ Kesehatan {
@fitsyu
fitsyu / CLGeocoder+Promises.swift
Last active Aug 2, 2019
Growing list of wrapped CLGeocoder with PromisesSwift
View CLGeocoder+Promises.swift
extension CLGeocoder {
func reverseGeocode(_ location: CLLocation) -> Promise<([CLPlacemark]?,Error?)> {
return wrap { self.reverseGeocodeLocation(location, completionHandler: $0) }
}
// add some more here later
}
@fitsyu
fitsyu / Singleton Snippet.swift
Created Jul 9, 2019
Quickly generate swift object singleton
View Singleton Snippet.swift
// MARK: Singleton Instance
private init() {}
private static var instance: <#T#>!
static var shared: <#T#> {
if instance == nil {
instance = <#T#>()
}
return instance
}
@fitsyu
fitsyu / Promises Snippet.swift
Created Jul 6, 2019
Quickly generate Google Promises code
View Promises Snippet.swift
let promise = Promise<<#T#>> { fulfill, reject in
}
return promise
@fitsyu
fitsyu / OneSectioned UITableView Snippet.swift
Last active Jul 6, 2019
A snippet to easily create the boilerplate UITableView DataSource and Delegate
View OneSectioned UITableView Snippet.swift
extension <#_#>: UITableViewDataSource {
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return <#models#>.count
}
@fitsyu
fitsyu / Useful.swift
Created Jun 26, 2019
Detect UIView out of screen
View Useful.swift
extension UIView {
func origin(in view: UIView) -> CGPoint {
return view.convert(CGPoint.zero, from: self)
}
func isVisible(in view: UIView) -> Bool {
return view.frame.contains(self.origin(in: view))
}
}
@fitsyu
fitsyu / SimpleTest5
Created Oct 19, 2018
Easy Easy Medium
View SimpleTest5
import UIKit
var str1 = "Hi"
var str2 = "World"
func twoString(s1: String, s2: String) -> String {
let filtered = str1.filter { char in str2.contains(char) }
let out = filtered.isEmpty ? "NO" : "YES"