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 Foundation | |
public class NaiveBayes { | |
/// initialize our vocabulary | |
private(set) var vocalbulary = Set<String>() | |
/// number of documents we have learned from | |
private(set) var totalDocuments = 0 | |
/// document frequency table for each of our categories | |
private(set) var docCount = [String: Int]() | |
/// for each category, how many words total were mapped to it |
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
// http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel | |
const popcnt = (v) => { | |
v -= (v >> 1) & 0x55555555 | |
v = (v & 0x33333333) + ((v >> 2) & 0x33333333) | |
return ((v + (v >> 4) & 0xf0f0f0f) * 0x1010101) >> 24 | |
} | |
// Fowler/Noll/Vo hashing. | |
const fnv_1a = (v) => { | |
let a = 2166136261 |
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
class TierTreeNode { | |
constructor() { | |
this.father = null | |
this.child = [] | |
this.keepChar = null | |
this.isWord = false | |
} | |
} | |
class TierTree { |
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 <React/RCTNetworking.h> | |
@interface RCTNetworkTask (SelfSignCert) | |
@end |
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
func isLatest(id: String, callback: @escaping (Bool?, Error?) -> Void) { | |
var components = URLComponents(string: "http://itunes.apple.com/lookup") | |
components?.queryItems = [URLQueryItem(name: "id", value: id)] | |
var request = URLRequest(url: (components?.url!)!) | |
request.httpMethod = "POST" | |
let task = URLSession.shared.dataTask(with: request) { (data, _, error) in | |
guard error == nil else { | |
callback(nil, error) | |
return | |
} |
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
GRect currentFrame = self.bounds; | |
CGContextSetLineJoin(context, kCGLineJoinRound); | |
CGContextSetLineWidth(context, strokeWidth); | |
CGContextSetStrokeColorWithColor(context, [MyPopupLayer popupBorderColor]); | |
CGContextSetFillColorWithColor(context, [MyPopupLayer popupBackgroundColor]); | |
// Draw and fill the bubble | |
CGContextBeginPath(context); | |
CGContextMoveToPoint(context, borderRadius + strokeWidth + 0.5f, strokeWidth + HEIGHTOFPOPUPTRIANGLE + 0.5f); |
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
// | |
// PhotoManager.swift | |
// EShopHelper | |
// | |
// Created by Jiang,Zhenhua on 2018/7/25. | |
// Copyright © 2018年 Daubert. All rights reserved. | |
// | |
import Foundation | |
import Photos |
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
/// 是否设置了代理 | |
/// | |
/// - Returns: 代理设置情况 | |
func getProxyStatus() -> Bool { | |
guard let proxySettings = CFNetworkCopySystemProxySettings()?.takeUnretainedValue(), | |
let url = URL(string: "https://www.baidu.com") else { | |
return false | |
} | |
let proxies = CFNetworkCopyProxiesForURL((url as CFURL), proxySettings).takeUnretainedValue() as NSArray | |
guard let settings = proxies.firstObject as? NSDictionary, |
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
[alias] | |
a = add | |
amend = commit --amend | |
c = commit | |
ca = commit --amend | |
ci = commit -a | |
co = checkout | |
d = diff | |
dc = diff --changed | |
ds = diff --staged |
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
// | |
// AudioProgressiveView.swift | |
// EShopHelper | |
// | |
// Created by Jiang,Zhenhua on 2018/10/16. | |
// Copyright © 2018 Daubert. All rights reserved. | |
// | |
import UIKit |