Skip to content

Instantly share code, notes, and snippets.

import UIKit
class PDFViewController: UIViewController, UIScrollViewDelegate {
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var pageControl: UIPageControl!
private var imageList: [UIImage] = []
@kazukitanaka0611
kazukitanaka0611 / CocoaLumberjack.swift
Last active August 29, 2015 14:16
CocoaLumberjack.swift
import UIKit
class LogFormatter: DDDispatchQueueLogFormatter, DDLogFormatter {
let threadUnsafeDateFormatter: NSDateFormatter
override init() {
threadUnsafeDateFormatter = NSDateFormatter()
threadUnsafeDateFormatter.formatterBehavior = .Behavior10_4
threadUnsafeDateFormatter.dateFormat = "HH:mm:ss.SSS"
super.init()
@kazukitanaka0611
kazukitanaka0611 / Swift 非同期テスト
Created March 4, 2015 04:12
Swift 非同期テスト
class TestAPI: NSObject {
func call(url: NSURL,
success handleSuccess: ((NSDictionary) -> Void)?,
failure handleFailure: ((NSError) -> Void)?) {
let request = NSURLRequest(URL: url)
let session = NSURLSession.sharedSession()
@kazukitanaka0611
kazukitanaka0611 / UIPageViewController
Created March 25, 2015 05:42
UIPageViewController
class ViewController: UIPageViewController, UIPageViewControllerDataSource {
private let imageNameList: [String] = ["ball.png", "neko.png"]
private var index: Int = 0
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
if let fileUTI = UTTypeCreatePreferredIdentifierForTag(
kUTTagClassFilenameExtension, fileName.pathExtension, nil) {
if UTTypeConformsTo(fileUTI.takeRetainedValue(), kUTTypePDF) != 0 {
NSLog("test")
}
}
import SpriteKit
class GameScene: SKScene {
private var mainCircle: SKSpriteNode!
override func didMoveToView(view: SKView) {
physicsBody = SKPhysicsBody(edgeLoopFromRect: self.frame)
@kazukitanaka0611
kazukitanaka0611 / gist:ac638b968aa6b16ddf34
Created January 15, 2016 03:53
Swift、クロージャ、循環参照するパターン
class MyClass {
var total: Int = 0
lazy var myFunc: (x: Int, y: Int) -> Void = {(x: Int, y: Int) in
self.total = x + y
}
deinit {
print("deinit")
@kazukitanaka0611
kazukitanaka0611 / how to use
Created May 24, 2016 03:23
UIImage+ImageEffects.h
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
UIImage *blurredImage = [[UIImage imageNamed:@"ball"] applyBlurWithRadius:1.5
tintColor:nil
saturationDeltaFactor:1.0
maskImage:nil];
dispatch_async(dispatch_get_main_queue(), ^{
_ballImageView.image = blurredImage;
void Update ()
{
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(target.position - transform.position), 0.3f);
transform.position += transform.forward * 0.1f;
}
@kazukitanaka0611
kazukitanaka0611 / HoloLens target ray roatate
Created February 8, 2017 14:20
HoloLens target ray roatate
public void OnInputClicked(InputClickedEventData eventData)
{
Vector3 headPosition = Camera.main.transform.position;
Vector3 gazeDirection = Camera.main.transform.forward;
RaycastHit hitInfo;
if (Physics.Raycast(headPosition, gazeDirection, out hitInfo, 30.0f, spatialMappingManager.LayerMask))
{
Instantiate(target, GazeManager.Instance.HitPosition, Quaternion.FromToRotation(Vector3.up, hitInfo.normal));
}