Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import argparse
import datetime
import os
import yaml
def main(args):
@shu223
shu223 / universal-framework.sh
Created April 27, 2017 23:27 — forked from cromandini/universal-framework.sh
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
@shu223
shu223 / CustomActivity.swift
Last active November 4, 2020 17:59
Custom UIActivity in Swift 3
import UIKit
class CustomActivity: UIActivity {
override class var activityCategory: UIActivityCategory {
return .action
}
override var activityType: UIActivityType? {
guard let bundleId = Bundle.main.bundleIdentifier else {return nil}
@shu223
shu223 / TensorFlow_TIPS.md
Last active February 12, 2018 18:01
TensorFlow TIPS
@shu223
shu223 / オープンソースAPI関連Tips.md
Last active December 12, 2017 06:32
オープンソースAPI関連Tips

メソッドの使用を禁止する

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

メソッド・プロパティをdeprecated/unavailableにする

@shu223
shu223 / duration_timestamp.md
Last active September 11, 2018 09:50
CADisplayLinkのメモ

##duration と timestamp

普通に初期化して、

CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(onTimer:)];
displayLink.frameInterval = 30;
[displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
self.displayLink = displayLink;
[self onTimer:self.displayLink];
@shu223
shu223 / AsyncMinimal.swift
Created April 6, 2016 17:27
Async https://github.com/duemunk/Async の `background` と `main` をチェーン実行するために必要な最小限のコードを抜き出したもの
public struct Async {
// MARK: - Private properties and init
/**
Private property to hold internally on to a `dispatch_block_t`
*/
private let block: dispatch_block_t
/**
@shu223
shu223 / SomeViewController.swift
Created February 28, 2016 07:09
Open one of Twitter apps with username
let username = organizer.twitter
let twitterURLs = [
"twitter://user?screen_name=\(username)", // Twitter
"tweetbot://user_profile/\(username)", // TweetBot
"echofon://user_timeline?\(username)", // Echofon
"twit://user?screen_name=\(username)", // Twittelator Pro
"x-seesmic://twitter_profile?twitter_screen_name=\(username)", // Seesmic
"x-birdfeed://user?screen_name=\(username)", // Birdfeed
"tweetings://user?screen_name=\(username)", // Tweetings
// Modified from: https://github.com/katleta3000/CancelBlocks/blob/master/CancelBlocks.swift
typealias dispatch_cancelable_block_t = (cancel: Bool) -> (Void)
private func dispatch_after_delay(delay: Double, queue: dispatch_queue_t, block: dispatch_block_t?) -> dispatch_cancelable_block_t? {
guard let block = block else { return nil }
var originalBlock: dispatch_block_t? = block
var cancelableBlock: dispatch_cancelable_block_t? = nil
let delayBlock: dispatch_cancelable_block_t = {(cancel: Bool) -> Void in
if let originalBlock = originalBlock where !cancel {
@shu223
shu223 / TextField.swift
Created January 20, 2016 08:25
Make the margins of UITextField editable in IB
@IBDesignable
class TextField: UITextField {
@IBInspectable var insetX: CGFloat = 0
@IBInspectable var insetY: CGFloat = 0
// placeholder position
override func textRectForBounds(bounds: CGRect) -> CGRect {
return CGRectInset(bounds , insetX , insetY)
}