Skip to content

Instantly share code, notes, and snippets.

View Appletone's full-sized avatar
💻
Coding

Lin Chia Hua Appletone

💻
Coding
  • Taipei, Taiwan
View GitHub Profile
@Appletone
Appletone / ViewController.swift
Last active March 17, 2016 16:43
評估你的 App 是否加入 Apple Watch 功能
//
// ViewController.swift
// WatchPairedExample
//
// Created by 張 景隆 on 2015/11/26.
// Copyright © 2015年 張 景隆. All rights reserved.
//
import UIKit
import WatchConnectivity
@Appletone
Appletone / 新新同文堂 bookmarklet
Last active June 19, 2019 02:32
新新同文堂.js
javascript:(function()%7Bvar%20s=document.getElementById(%22tongwenlet_tw%22);if(s!=null)%7Bdocument.body.removeChild(s);%7Dvar%20s=document.createElement(%22script%22);s.language=%22javascript%22;s.type=%22text/javascript%22;s.src=%22https://raw.githubusercontent.com/stargazer8tw/samples/fe8d4f5d89aebff0359b7f3ea52e141a1d92dcf5/tongwen_bookmarklet/js/bookmarklet_tw.js%22;s.id=%22tongwenlet_tw%22;document.body.appendChild(s);%20%7D)();
extension WKInterfaceController {
func animateWithDuration(duration: NSTimeInterval, animations: () -> Void, completion: (() -> Void)?) {
animateWithDuration(duration, animations: animations)
let delay = dispatch_time(DISPATCH_TIME_NOW, Int64(duration * Double(NSEC_PER_SEC)))
dispatch_after(delay, dispatch_get_main_queue()) {
completion?()
}
}
@Appletone
Appletone / Objective-C the get property name string for a class and check it at compile-time.md
Last active August 29, 2016 12:02 — forked from xareelee/NSObject+PropertyName.h
Objective-C the get property name string for a class and check it at compile-time

A simple idea using the trick of keypath(...) derived from libextobjc and ReactiveCocoa and null-object pattern.

Create a category method in NSObject and define a macro PropertyNameForClass().


NSObject+PropertyName.h:

#import 
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//Add some method process in global queue - normal for data processing
dispatch_async(dispatch_get_main_queue(), ^(){
//Add method, task you want perform on mainQueue
//Control UIView, IBOutlet all here
});
@import Foundation;
@interface KKWatchAppNotificationCenter : NSObject
+ (instancetype)sharedCenter;
- (void)postNotification:(NSString *)key;
- (void)addTarget:(id)target selector:(SEL)selector name:(NSString *)notification;
- (void)removeObserver:(NSObject *)observer;
@end
@Appletone
Appletone / 0_reuse_code.js
Last active August 29, 2015 14:06
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
@Appletone
Appletone / gist:d8d2cbd91c5dbe05861c
Last active August 29, 2015 14:04
Swift postfix function like Linux Shell background operator
// define Swift postfix function like Linux Shell background operator
operator postfix & {}
@postfix func & (backgroundClosure: () -> ()) {
dispatch_async(_queue) {
backgroundClosure()
}
}
// testing log function
func log(message: String)
import Foundation
extension Int {
var days:Int {
return 60*60*24*self
}
var ago:NSDate {
return NSDate().dateByAddingTimeInterval(-Double(self))
}
}
@Appletone
Appletone / FBTweak
Last active August 29, 2015 14:03
How to use Facebook Tweaks (FBTweak)
// app delegate
#import <FBTweak.h>
#import <FBTweakShakeWindow.h>
#import <FBTweakInline.h>
#import <FBTweakViewController.h>
#ifdef DEBUG
BOOL static const IS_DEBUG = YES;
#else
BOOL static const IS_DEBUG = NO;