# 查询 docker 命令
docker --help
# 停止 docker 服务
sudo service docker stop
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 { | |
mutating public func setValue(value: Any, forKeyPath keyPath: String) { | |
var keys = keyPath.components(separatedBy: ".") | |
guard let first = keys.first as? Key else { print("Unable to use string as key on type: \(Key.self)"); return } | |
keys.remove(at: 0) | |
if keys.isEmpty, let settable = value as? Value { | |
self[first] = settable | |
} else { | |
let rejoined = keys.joined(separator: ".") | |
var subdict: [NSObject : AnyObject] = [:] |
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
# thanks to https://gist.github.com/dergachev/4627207 | |
ffmpeg -i Wave.mov -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > out.gif |
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
NSString *s = @"😀"; | |
__block NSInteger count = 0; | |
[s enumerateSubstringsInRange:NSMakeRange(0, s.length) options:NSStringEnumerationBySentences usingBlock:^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) { | |
count++; | |
}]; | |
NSLog(@"%d", count); |
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
- (NSString *)responseString | |
{ | |
NSData *data = [self responseData]; | |
if (!data) { | |
return nil; | |
} | |
//明确表示用 gbkEncoding 进行解码 | |
NSStringEncoding gbkEncoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000); | |
return [[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding:gbkEncoding]; | |
} |
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
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<!-- array of downloads. --> | |
<key>items</key> | |
<array> | |
<dict> | |
<!-- an array of assets to download --> |
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
// original : https://stackoverflow.com/questions/24303883/uicollectionview-with-paging-enable | |
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView | |
withVelocity:(CGPoint)velocity | |
targetContentOffset:(inout CGPoint *)targetContentOffset | |
{ | |
CGFloat cellWidth = self.cellWidth; | |
CGFloat cellPadding = 9; | |
NSInteger page = (scrollView.contentOffset.x - cellWidth / 2) / (cellWidth + cellPadding) + 1; |
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 static NSString * const strings[] = { | |
[0] = @"string_1", | |
[1] = @"string_2", | |
[2] = @"string_3", | |
[3] = @"string_4", | |
// ... | |
}; |
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
// import the library | |
import PropTypes from 'prop-types'; | |
// define a component | |
class Greeting extends React.Component { | |
render() { | |
return ( | |
<h1>Hello, {this.props.name}</h1> | |
); | |
} |
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
import React, { Component } from 'react' | |
import { AppRegistry, View, Text, ActivityIndicator, ScrollView, StyleSheet } from 'react-native' | |
class App extends Component { | |
state = { | |
loading: true, | |
error: false, | |
posts: [], | |
} |