Skip to content

Instantly share code, notes, and snippets.

Avatar

Yoichi Tagaya yoichitgy

View GitHub Profile
@yoichitgy
yoichitgy / Playground-MercariTechConf2017-DIContainer.swift
Last active Oct 1, 2017
Mercari Tech Conf 2017 - Demo implementing a simple dependency injection container
View Playground-MercariTechConf2017-DIContainer.swift
protocol Animal {
func sound() -> String
}
class Cat: Animal {
func sound() -> String { return "😺Meow" }
}
class Dog: Animal {
func sound() -> String { return "🐶Bow wow" }
}
@yoichitgy
yoichitgy / ViewController.swift
Created Sep 16, 2017
iOSDC JAPAN 2017 Demo - ViewController.swift
View ViewController.swift
import UIKit
class ViewController: UIViewController {
private var count = 0
override func viewDidLoad() {
super.viewDidLoad()
Log.info(message: "viewDidLoad")
Log.info(message: "API: GET /some/values")
Log.info(message: "User did something.")
@yoichitgy
yoichitgy / AppDelegate.swift
Created Sep 16, 2017
iOSDC JAPAN 2017 Demo - AppDelegate.swift
View AppDelegate.swift
import UIKit
import Fabric
import Crashlytics
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Fabric.with([Crashlytics.self])
@yoichitgy
yoichitgy / Log.swift
Created Sep 16, 2017
iOSDC JAPAN 2017 Demo - Log.swift
View Log.swift
import Foundation
import os.log
import Crashlytics
final class Log {
private init() {}
static func debug(message: String) {
writeLog(message: message, level: .debug)
}
@yoichitgy
yoichitgy / CakePatternExample.swift
Created Apr 4, 2017
Cake Pattern Example in Swift (Demo at iOSCon 2017 in London)
View CakePatternExample.swift
// Demo at iOSCon 2017 in London
// https://speakerdeck.com/yoichitgy/dependency-injection-in-practice-ioscon
//
// How to Use: Paste this program to a Playground.
// Tested with: Xcode 8.2.1
// Interface (protocol)
protocol Logger {
func log(_ message: String)
}
@yoichitgy
yoichitgy / SwinjectExample.swift
Created Apr 4, 2017
Swinject Example (Demo at iOSCon 2017 in London)
View SwinjectExample.swift
// Demo at iOSCon 2017 in London
// https://speakerdeck.com/yoichitgy/dependency-injection-in-practice-ioscon
//
// Tested with: Xcode 8.2.1
//
// How to Use:
// 1. Clone Swinject: git clone --recursive git@github.com:Swinject/Swinject.git
// 2. Checkout 2.0.0 branch: cd Swinject; git checkout 2.0.0
// 3. Build the Swinject project for a simulator target
// 4. Open the playground in the project
@yoichitgy
yoichitgy / SimpleDIContainer.swift
Last active Jul 11, 2019
Simple DI Container in Swift (Demo at iOSCon 2017 in London)
View SimpleDIContainer.swift
// Demo at iOSCon 2017 in London
// https://speakerdeck.com/yoichitgy/dependency-injection-in-practice-ioscon
//
// How to Use: Paste this program to a Playground.
// Tested with: Xcode 8.2.1
protocol Animal: class { }
class Cat: Animal { }
class Dog: Animal { }
@yoichitgy
yoichitgy / hugodeploy
Last active Oct 21, 2017
A bash script to deploy GitHub Pages with Hugo.
View hugodeploy
#!/bin/bash
while getopts p option
do
case $option in
p) opt_p=TRUE ;;
esac
done
if [ ! -d "public" ]
@yoichitgy
yoichitgy / genassetimages.sh
Created Mar 17, 2015
A script to generates iOS asset PNG images from a PSD file for @1x, @2x and @3x scales.
View genassetimages.sh
#!/bin/sh
#
# genassetimages.sh
# Generates iOS asset PNG images from a PSD file for @1x, @2x and @3x scales.
# ImageMagick is used to resize the images.
#
# settings ==========
outputDir="image_assets"
assetSuffixes=(".png" "@2x.png" "@3x.png")
@yoichitgy
yoichitgy / mergegenstrings.py
Last active Jun 10, 2020
A script to generate .strings file for .swift, .m, .storyboard and .xib files by genstrings and ibtool commands, and merge them with existing translations.
View mergegenstrings.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Localize.py - Incremental localization on XCode projects
# João Moreno 2009
# http://joaomoreno.com/
# Modified by Steve Streeting 2010 http://www.stevestreeting.com
# Changes
# - Use .strings files encoded as UTF-8
You can’t perform that action at this time.