Skip to content

Instantly share code, notes, and snippets.

View sarunw's full-sized avatar
🍎
iOS, Swift, SwiftUI

Sarun Wongpatcharapakorn sarunw

🍎
iOS, Swift, SwiftUI
View GitHub Profile
@sarunw
sarunw / 11ty_contains.js
Created July 27, 2019 11:57 — forked from danfascia/11ty_contains.js
11ty filter to filter a collection (array) by key:value pair - used to filter on custom taxonomies other than tags (source: https://paulrobertlloyd.com/)
/**
* Select objects in array whose key includes a value
*
* @param {Array} arr Array to test
* @param {String} key Key to inspect
* @param {String} value Value key needs to include
* @return {String} Filtered array
*
*/
module.exports = function (arr, key, value) {
@sarunw
sarunw / 11ty_is.js
Created July 27, 2019 11:57 — forked from danfascia/11ty_is.js
11ty filter to filter items in a collection (array) whose key === value. (source: https://paulrobertlloyd.com/)
/**
* Select objects in array whose key matches a value
*
* @param {Array} arr Array to test
* @param {String} key Key to inspect
* @param {String} value Value key needs to match
* @return {String} Filtered array
*
*/
module.exports = function (arr, key, value) {
@sarunw
sarunw / webpacker_rails.md
Created May 30, 2019 16:02 — forked from maxivak/webpacker_rails.md
Webpack, Yarn, Npm in Rails
@sarunw
sarunw / README.md
Created May 29, 2019 19:20 — forked from bazzel/README.md
Webpacker and I18n
$ rails new my-i8n --webpack

Gemfile

gem 'i18n-js'
version=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$PROJECT_DIR/$INFOPLIST_FILE")
build=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$PROJECT_DIR/$INFOPLIST_FILE")
/usr/libexec/PlistBuddy -c "Set PreferenceSpecifiers:0:DefaultValue $version ($build)" "$SRCROOT/FunWithSettings/Settings.bundle/Root.plist"
<?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>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
@sarunw
sarunw / Child.plist
Created January 9, 2019 07:45
Settings-Child
<?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>StringsTable</key>
<string>Child</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
@sarunw
sarunw / Root.plist
Created January 9, 2019 07:44
Settings-root
<?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>StringsTable</key>
<string>Root</string>
<key>PreferenceSpecifiers</key>
<array>
<dict>
<key>Type</key>
// 1
protocol ProductListViewControllerDelegate: class {
func productListViewController(_ vc: ProductListViewController, didSelectProduct product: Product)
}
class ProductListViewController: UIViewController {
weak var delegate: ProductListViewControllerDelegate?
}
protocol ProductDetailViewControllerDelegate: class {
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
private var purchaseCoordinator: PurchaseCoordinator
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)