- 角色
- 發佈
- 週邊(peripheral)
- 廣播(broadcast)
- 中心(central)
- 掃瞄(scan)
- 週邊(peripheral)
- 連線
- server
- client
- 發佈
- 搭配
This file contains hidden or 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 | |
} | |
} |
This file contains hidden or 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 hidden or 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
@implementation UILabel (PLUS) | |
- (void)setHtml:(NSString*)text { | |
NSString *color = [self hexFromUIColor:self.textColor]; | |
NSString *html = [NSString stringWithFormat:@"<html><head><style type=\"text/css\">\ | |
body {font-family: '%@'; font-size:%@px;color: %@;}\ | |
a {color: %@;}\ | |
</style></head><body>%@</body></html>", | |
self.font.fontName, @(self.font.pointSize), color, |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
import UIKit | |
class NSURLSessionPinningDelegate: NSObject, URLSessionDelegate { | |
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Swift.Void) { | |
if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) { | |
if let trust = challenge.protectionSpace.serverTrust, | |
let pem = Bundle.main.path(forResource: "https", ofType: "cer"), | |
let data = NSData(contentsOfFile: pem), |
This file contains hidden or 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]; | |