Skip to content

Instantly share code, notes, and snippets.

@yoichitgy
yoichitgy / mergegenstrings.py
Last active July 9, 2022 23:59
A script to generate .strings file for .swift, .m, .storyboard and .xib files by genstrings and ibtool commands, and merge them with existing translations.
#!/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
@yoichitgy
yoichitgy / hugodeploy
Last active July 1, 2022 18:19
A bash script to deploy GitHub Pages with Hugo.
#!/bin/bash
while getopts p option
do
case $option in
p) opt_p=TRUE ;;
esac
done
if [ ! -d "public" ]
@yoichitgy
yoichitgy / SimpleDIContainer.swift
Last active July 11, 2019 19:08
Simple DI Container in Swift (Demo at iOSCon 2017 in London)
// 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 / Log.swift
Created September 16, 2017 06:28
iOSDC JAPAN 2017 Demo - 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 / Playground-MercariTechConf2017-DIContainer.swift
Last active October 1, 2017 02:07
Mercari Tech Conf 2017 - Demo implementing a simple dependency injection container
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 September 16, 2017 06:29
iOSDC JAPAN 2017 Demo - 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 September 16, 2017 06:29
iOSDC JAPAN 2017 Demo - 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 / CakePatternExample.swift
Created April 4, 2017 03:02
Cake Pattern Example in Swift (Demo at iOSCon 2017 in London)
// 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 April 4, 2017 02:54
Swinject Example (Demo at iOSCon 2017 in London)
// 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 / genscreenshots.sh
Created March 13, 2015 11:40
A shell script to generates screenshot images from PSD files to submit to iTunes Connect (App Store). It removes the alpha channel of the source 5.5 inch images, and resizes and crops them to generate 4.7, 4 and 3.5 inch images.
#!/bin/sh
# settings ==========
filePrefix=""
destDir="./output/"
destDir5_5=$destDir"5.5inch/"
destDir4_7=$destDir"4.7inch/"
destDir4=$destDir"4inch/"
destDir3_5=$destDir"3.5inch/"