Skip to content

Instantly share code, notes, and snippets.

View koingdev's full-sized avatar
🤖
Stay focus

Saingkoing SEA koingdev

🤖
Stay focus
  • Tokyo, Japan
View GitHub Profile
@koingdev
koingdev / Fastfile
Created December 29, 2021 07:14
Fastlane to upload TestFlight on pushing git tag
lane :upload_testflight_on_pushing_tag do |options|
# Tag: Release-1.0.0-100 (Release-Version-Build)
tag_components = sh("git tag --sort=taggerdate | tail -1").split("-")
version = tag_components[1]
build = tag_components[2]
# Increment version and build number
increment_version_and_build_number(version: version, build: build)
# Generate iPA
@koingdev
koingdev / solid-principle.md
Last active June 20, 2022 09:57
S.O.L.I.D Design Principe Explanation with Example by me

Single-responsibility Principle

A class should have only one responsibility.

Bad

class ViewController: UIViewController {
	func fetchDataFromServer() { //Perform network request code... }
	func insertDataIntoDatabase() { //Perform database insertion code... }
@koingdev
koingdev / Brightness.swift
Created June 26, 2020 07:36
Simple Swift Brightness Manager class
final class Brightness {
// Config
private let maxBrightness: CGFloat
private(set) var defaultBrightness: CGFloat = 1.0
var isEnabled = true {
didSet {
if isEnabled {
@koingdev
koingdev / ToolTipView.swift
Created June 26, 2020 07:34
Simple UIView class to display tooltip in iOS
/// Display ToolTip View
///
/// Example:
/// ```swift
/// let paragraph = NSMutableParagraphStyle()
/// paragraph.lineSpacing = 18
/// let attributes = [
/// NSAttributedString.Key.font : UIFont.systemFont(ofSize: 16),
/// NSAttributedString.Key.foregroundColor : UIColor.white,
/// NSAttributedString.Key.paragraphStyle : paragraph
@koingdev
koingdev / UIButton+LoadingIndicator.swift
Created February 6, 2020 15:20
Simple and easy way to show loading indicator inside UIButton in Swift
extension UIButton {
func loadingIndicator(show: Bool, style: UIActivityIndicatorView.Style = .medium, color: UIColor = .white) {
let tag = 10042017
if show {
isEnabled = false
titleLabel?.alpha = 0
let indicator = UIActivityIndicatorView(style: style)
indicator.color = color
indicator.center = CGPoint(x: bounds.size.width / 2, y: bounds.size.height / 2)
indicator.tag = tag
@koingdev
koingdev / clean_code.md
Created August 2, 2019 08:53 — forked from wojteklu/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@koingdev
koingdev / 0.README.md
Last active August 16, 2019 06:50
Make AWS Amplify support custom fields (Mutation/Query)
  1. Add new custom schema to schema.graphql file

  2. Create custom request/response mapping resolvers file in resolvers folder. The file should look like this:

    • REQUEST_MAPPING: Mutation.putUser.req.vtl
    • RESPONSE_MAPPING: Mutation.putUser.res.vtl
  3. Update CustomResources.json file in stack folder

@koingdev
koingdev / putitem-if-not-exist.vtl
Created July 22, 2019 09:41
AppSync Resolver PutItem with Condition Prevent Data Overwrite
{
"version" : "2017-02-28",
"operation" : "PutItem",
"key" : {
"shopID": $util.dynamodb.toDynamoDBJson($ctx.args.shopID),
"vendorID": $util.dynamodb.toDynamoDBJson($ctx.args.vendorID)
},
"attributeValues": {
"name": $util.dynamodb.toDynamoDBJson($ctx.args.name)
},
@koingdev
koingdev / query-sort-by-rangekey.vtl
Created July 22, 2019 09:36
Query items with PK and response in an order based on range key
{
"version" : "2017-02-28",
"operation" : "Query",
"query" : {
"expression" : "author = :author",
"expressionValues" : {
":author" : $util.dynamodb.toDynamoDBJson($ctx.args.author)
}
},
## false -> DESC ORDER
@koingdev
koingdev / putitem-conflict-resolution.vtl
Created July 22, 2019 09:33
Sample AppSync Resolver for PutItem Operation including with Conflict Resolution
{
"version" : "2017-02-28",
"operation" : "PutItem",
"key" : {
"shopID" : $util.dynamodb.toDynamoDBJson($ctx.args.shopID),
"id": $util.dynamodb.toDynamoDBJson($ctx.args.id)
},
"attributeValues" : {
"staffName" : $util.dynamodb.toDynamoDBJson($ctx.args.staffName),
"modifiedDate": $util.dynamodb.toDynamoDBJson($ctx.args.modifiedDate),