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
class UserBuilder { | |
var name: String | |
var gender: String | |
init() { | |
self.name = "default name" | |
self.gender = "default gender" | |
} | |
} |
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
sudo pmset -a GPUSwitch 0 | |
0 ,强制使用核显, | |
1 , 强制使用独显, | |
2 ,自动切换图形卡 |
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
#include <stdio.h> | |
/* | |
* 基姆拉尔森计算公式 | |
* W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7 | |
*/ | |
int week(int y, int m, int d) | |
{ | |
if (m < 3) { | |
m += 12; |
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
private func escapedParameters(parameters: [String:AnyObject]) -> String { | |
if parameters.isEmpty { | |
return "" | |
} else { | |
var keyValuePairs = [String]() | |
for (key, value) in parameters { | |
// make sure that it is a string value |
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 Dictionary where Value: Equatable { | |
/// Returns all keys mapped to the specified value. | |
/// ``` | |
/// let dict = ["A": 1, "B": 2, "C": 3] | |
/// let keys = dict.keysForValue(2) | |
/// assert(keys == ["B"]) | |
/// assert(dict["B"] == 2) | |
/// ``` | |
func keysForValue(value: Value) -> [Key] { | |
return flatMap { (key: Key, val: Value) -> Key? in |
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
// approach one | |
extension String { | |
var length: Int { | |
return characters.count | |
} | |
} | |
// approach two | |
extension String { | |
var length: Int { | |
return (self as NSString).length |