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 / ExportOptions.plist
Last active October 15, 2025 06:22
Script to automatically upload iOS App to AppStore and TestFlight (including versioning)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>destination</key>
<string>upload</string>
<key>method</key>
<string>app-store</string>
<key>provisioningProfiles</key>
<dict>
@koingdev
koingdev / FlattenNestedDictionary.swift
Created June 5, 2019 13:46
Make nested dictionary flat again
/*
BEFORE = ["id": 1, "sergio": ["yume": ["ssk": 999]], "product": ["name": "AAA", "description": ["banana": "yellow"]]]
AFTER = ["sergio/yume/ssk": 999, "id": 1, "product/name": "AAA", "product/description/banana": "yellow"]
*/
typealias JSON = [String : Any]
let nested: JSON = ["id": 1, "product": ["name": "AAA", "description": ["banana": "yellow"]], "sergio": ["yume": ["ssk": 999]]]
extension JSON where Key: ExpressibleByStringLiteral, Value: Any {
@koingdev
koingdev / query-local-secondary-index.vtl
Created July 22, 2019 09:25
Sample AppSync Resolver for Query Local Secondary Index
## REQUEST MAPPING
{
"version" : "2017-02-28",
"operation" : "Query",
"index": "shopID-vendorID-index",
"query" : {
"expression": "shopID = :shopID AND vendorID = :vendorID",
"expressionValues" : {
":shopID" : $util.dynamodb.toDynamoDBJson($ctx.args.shopID),
":vendorID" : $util.dynamodb.toDynamoDBJson($ctx.args.vendorID)
@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),
@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-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 / 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 / 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 / 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 / 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