Skip to content

Instantly share code, notes, and snippets.

View zaimramlan's full-sized avatar
👨‍💻
Engineering

Zaim Ramlan zaimramlan

👨‍💻
Engineering
View GitHub Profile
@zaimramlan
zaimramlan / export-import-update-delete-github-labels.md
Last active August 6, 2020 15:17 — forked from Isaddo/import-github-labels.js
Export, Import, Update, Delete GitHub labels via browser console command

Usage

  • This script allows export, import, update and delete of GitHub Labels
  • Adopted from Isaddo's gist with some tweaks for 2020
  • Included a delete script too

Export Labels

  1. Go to the source repository's labels page
  2. Open up the browser console
  3. Copy and paste the following script & copy its output

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

Keybase proof

I hereby claim:

  • I am zaimramlan on github.
  • I am zaimramlan (https://keybase.io/zaimramlan) on keybase.
  • I have a public key ASCylfPWAfsIsY1IQV_X_kdov1XQqkUotNgeE9veGRAIpQo

To claim this, I am signing this object:

@zaimramlan
zaimramlan / playground_associated_enum_rawvalues.swift
Last active August 6, 2019 06:29
[PLAYGROUND] Associated Enum RawValues
import Foundation
enum Parameter {
enum Module {
case partner(PartnerValues)
enum Keys: String {
case partner
}
@zaimramlan
zaimramlan / playground_simplify_storyboard_instantiation.swift
Created July 28, 2019 09:04
[PLAYGROUND] Simplify Storyboard Instantiation
import UIKit
enum Storyboard: String {
case SignUp
case TopUp
}
enum ViewController {
enum SignUp: String {
case createAccount = "CreateAccountVC"
@zaimramlan
zaimramlan / playground_reusable_dictionaryable_protocol.swift
Created June 13, 2019 17:53
[PLAYGROUND] Reusable Dictionaryable Protocol
import Foundation
protocol Dictionaryable {
var keys: [String] { get }
var values: [Any] { get }
}
extension Dictionaryable where Self: Codable {
func toDictionary() -> Dictionary<String, AnyObject> {
var dictionary = Dictionary<String, AnyObject>()
@zaimramlan
zaimramlan / scaled_asset_url_string.swift
Created May 20, 2019 00:12
[Swift] Scaled Asset URL String
import UIKit
extension String {
private var isURLString: Bool {
return URL(string: self) != nil
}
private var isAssetURL: Bool {
let asset = self.components(separatedBy: ".").last
return asset == "png" || asset == "jpg" || asset == "pdf"
@zaimramlan
zaimramlan / CustomPannableView.swift
Created November 13, 2018 19:15
A pannable view class to quickly apply pan gestures onto a UIView to slide vertically, reset to original position and close the view.
class CustomPannableView: UIView {
// MARK: Properties
private typealias BottomSheetStyle = StyleConstants.Views.BottomSheet
private var minimumVelocityToHide = BottomSheetStyle.minimumPanningVelocityToAutoHide
private var minimumScreenRatioToHide = BottomSheetStyle.minimumPositionRatioToAutoHide
private var animationDuration = BottomSheetStyle.animationDuration
private var parentView: UIView?
private var completion: (() -> ())?
@zaimramlan
zaimramlan / String+Formatting.swift
Created October 27, 2018 22:18
Swift's String(format:arguments:) method (peeking under the hood)
extension String {
/// Replaces format specifiers (with index) with given arguments.
/// (Only works if given arguments are Strings and to replace Strings)
///
/// - Parameter arguments: List of String replacements.
/// - Returns: This String replaced with given Strings (unless arguments are not a String array)
func replaceFormatSpecifiersWithIndex(with arguments: CVarArg...) -> String {
guard let args = arguments as? [String] else { return self }
@zaimramlan
zaimramlan / breaking_strong_reference_cycle_in_closures.swift
Created August 20, 2018 00:20
Breaking strong reference cycle in closures
import Foundation
class User {
var firstName: String
var lastName: String
// Comment this to see strong reference cycle
lazy var fullName: () -> String = {
[weak self] in
guard let strongSelf = self else { return "No name specified." }