Skip to content

Instantly share code, notes, and snippets.

@ginowu7
ginowu7 / ab_test_maintenance.swift
Created February 8, 2019 17:00
Parsing comment blocks for AB_TEST
func validateABTests(file: String) {
let declaredVariantFile = findPath(file)
let variantContents = contents(atPath: declaredVariantFile)
let variantTests = regexFor("(.*//\\s*AB_TEST.*)", content: variantContents)
variantTests.forEach {
guard let expirationDateSerialized = regexFor("((0|1)\\d{1})/((0|1|2)\\d{1})/((19|20)\\d{2})", content: $0).first,
let expirationDate = dateFormatter.date(from: expirationDateSerialized) else {
fatalError("Incorrect expiration date format: MM/dd/yyyy")
}
@ginowu7
ginowu7 / clean_localizable_full.sh
Created August 30, 2018 14:00
Clean Localizable Script Full
#!/usr/bin/xcrun --sdk macosx swift
import Foundation
let fileManager = FileManager.default
let currentPath = fileManager.currentDirectoryPath
/// List of files in currentPath - recursive
var pathFiles: [String] = {
guard let enumerator = fileManager.enumerator(atPath: currentPath),
@ginowu7
ginowu7 / clean_localizable.swift
Last active September 21, 2018 04:08
Clean swift localizable script
/// Throws error if ALL localizable files does not have matching keys
///
/// - Parameter files: list of localizable files to validate
func validateMatchKeys(_ files: [LocalizationStringsFile]) {
print("------------ Validating keys match in all localizable files ------------")
guard let base = files.first, files.count > 1 else { return }
let files = Array(files.dropFirst())
files.forEach {
guard let extraKey = Set(base.keys).symmetricDifference($0.keys).first else { return }
let incorrectFile = $0.keys.contains(extraKey) ? $0 : base
@ginowu7
ginowu7 / 0_reuse_code.js
Created October 10, 2016 14:23
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console