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
// get the height of the status bar | |
let statusBarHeight = UIApplication.shared.statusBarFrame.height |
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
tableView.backgroundColor = UIColor(red:1, green:1, blue:1, alpha:1.00) | |
let backgroundImageView = UIImageView(frame: view.bounds) | |
backgroundImageView.image = UIImage(named: "background") | |
backgroundImageView.alpha = 0.5 | |
tableView.backgroundView = backgroundImageView |
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
// MARK: - Data Persistence | |
func documentsDirectory() -> URL { | |
let paths = FileManager.default.urls(for: .documentDirectory, | |
in: .userDomainMask) | |
return paths[0] | |
} | |
func dataFilePath() -> URL { | |
return documentsDirectory().appendingPathComponent("Checklists.plist") | |
} |
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 Foundation | |
do { | |
//要做一些操作 | |
let str = try NSString(contentsOfFile: filePath,encoding: NSUTF8StringEncoding)//要尝试做的事情 | |
} catch let err as NSError {//如果失败则进入catch代码块 |
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
add_filter( 'get_the_archive_title', function ($title) { | |
if ( is_category() ) { | |
$title = single_cat_title( '', false ); | |
} elseif ( is_tag() ) { | |
$title = single_tag_title( '', 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
Swift 3 (Xcode 8) | |
```swift | |
func matches(for regex: String, in text: String) -> [String] { | |
do { | |
let regex = try NSRegularExpression(pattern: regex) | |
let nsString = text as NSString | |
let results = regex.matches(in: text, range: NSRange(location: 0, length: nsString.length)) | |
return results.map { nsString.substring(with: $0.range)} | |
} catch let error { |
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
https://stackoverflow.com/a/30404532 | |
As of Swift 4 (Xcode 9), the Swift standard library provides methods to convert between Swift string ranges (Range<String.Index>) and NSString ranges (NSRange). Example: | |
let str = "a👿b🇩🇪c" | |
let r1 = str.range(of: "🇩🇪")! | |
// String range to NSRange: | |
let n1 = NSRange(r1, in: str) | |
print((str as NSString).substring(with: n1)) // 🇩🇪 |
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
+__rvm_make:0> make -j 1 | |
CC = gcc | |
LD = ld | |
LDSHARED = gcc -dynamiclib | |
CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe | |
XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT | |
CPPFLAGS = -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -I. -I.ext/include/x86_64-darwin17 -I./include -I. | |
DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -install_name /Users/jun/.rvm/rubies/ |
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
// To write a pluggable function, you simply enclose it in a conditional tag to check if a function with that name has already been run: | |
<?php | |
if ( ! function_exists ( 'my_function' ) ) { | |
function my_function() { | |
// Contents of your function here. | |
} | |
} | |
?> | |
Then when you come to write a function in your child theme which you want to override the one in the parent theme, you just give it the same name as the one in the parent theme: |
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
<ul> | |
<?php | |
$args=array( | |
'cat' => 1, // 分类ID | |
'posts_per_page' => 10, // 显示篇数 | |
); | |
query_posts($args); | |
if(have_posts()) : while (have_posts()) : the_post(); | |
?> |
OlderNewer