This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define LIST_OF_ServerAPI \ | |
/*會員*/ \ | |
api(登入, member/login) \ | |
api(FB登入, member/fbLogin) | |
typedef NS_ENUM(NSInteger, ServerAPI) { | |
#define api(key, name) key, | |
LIST_OF_ServerAPI | |
#undef api | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef L | |
#define L(key) [NSBundle.mainBundle localizedStringForKey:(key)] | |
#endif | |
@interface NSBundle (NSLocalizedString_Base) | |
- (NSString *)localizedStringForKey:(NSString *)key; | |
@end | |
@implementation NSBundle (NSLocalizedString_Base) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func crashReporterScreenCapture(info:UnsafeMutablePointer<siginfo_t>, uap:UnsafeMutablePointer<ucontext_t>, context:UnsafeMutablePointer<Void>) { | |
} | |
var crashReporterCapture = PLCrashReporterCallbacks() | |
crashReporterCapture.version = 0 | |
crashReporterCapture.context = nil | |
crashReporterCapture.handleSignal = crashReporterScreenCapture | |
crashReporter.setCrashCallbacks(&crashReporterCapture) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UILabel *label = [[UILabel alloc] initWithFrame:tableView.bounds]; | |
label.numberOfLines = 0; | |
NSMutableAttributedString *attachmentString = [NSMutableAttributedString new]; | |
NSTextAttachment *imageAttachment = [NSTextAttachment new]; | |
imageAttachment.image = [UIImage imageNamed:images[index]]; | |
NSAttributedString *imageString = [NSAttributedString attributedStringWithAttachment:imageAttachment]; | |
[attachmentString appendAttributedString:imageString]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public protocol DataConvertible { | |
static func + (lhs: Data, rhs: Self) -> Data | |
static func += (lhs: inout Data, rhs: Self) | |
} | |
extension DataConvertible { | |
public static func + (lhs: Data, rhs: Self) -> Data { | |
var value = rhs | |
let data = Data(buffer: UnsafeBufferPointer(start: &value, count: 1)) | |
return lhs + data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ob_start(); | |
function send($data) { | |
$token = file_get_contents('.token'); | |
$url = 'https://graph.facebook.com/v2.6/me/messages?access_token='.$token; | |
$content = json_encode($data); | |
$curl = curl_init($url); | |
curl_setopt($curl, CURLOPT_HEADER, false); | |
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator |>: AdditionPrecedence | |
public func |> <T,U>(lhs: T, rhs: (T) -> U) -> U { | |
return rhs(lhs) | |
} | |
public func |> <T>(lhs: T, rhs: inout T) { | |
rhs = lhs | |
} | |
infix operator <|: AdditionPrecedence |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension StringTransform { | |
public static let 简 = StringTransform("Hant-Hans") | |
public static let 繁 = StringTransform("Hans-Hant") | |
public static let 拼 = StringTransform("Han-Latin") | |
public static let 注 = StringTransform("Han-Latin;Latin-Bopomofo") | |
} | |
let 繁转简 = "繁轉簡".applyingTransform(.简, reverse: false) | |
let 簡轉繁 = "简转繁".applyingTransform(.繁, reverse: false) | |
let pīnyīn = "拼音".applyingTransform(.拼, reverse: false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { createStore, bindActionCreators } = Redux | |
const reducer = (state = {紅:0, 綠:0, 藍:0}, action) => { | |
switch (action.type){ | |
case '紅': return {...state, 紅:action.值} | |
case '綠': return {...state, 綠:action.值} | |
case '藍': return {...state, 藍:action.值} | |
default: return state | |
} | |
} |
OlderNewer