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
zend_class_entry *wcx_exception_ce; | |
PHP_WCX_API zend_class_entry *wcx_get_exception_base(int root TSRMLS_DC) { | |
#if HAVE_SPL | |
if (!root) { | |
if (!spl_ce_RuntimeException) { | |
zend_class_entry **pce; | |
if (zend_hash_find(CG(class_table), "runtimeexception", sizeof("RuntimeException"), (void **) &pce) == SUCCESS) { | |
spl_ce_RuntimeException = *pce; | |
return *pce; |
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
char *host=NULL; | |
int host_len; | |
host_len = spprintf(&host, 0, "%s:%d", redis_sock->host, redis_sock->port); |
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://github.com/mattsta/krmt | |
static int sort_gp_asc(const void *a, const void *b) { | |
const struct geojsonPoint *gpa = a, *gpb = b; | |
/* We can't do adist - bdist because they are doubles and | |
* the comparator returns an int. */ | |
if (gpa->dist > gpb->dist) | |
return 1; | |
else if (gpa->dist == gpb->dist) | |
return 0; |
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 <math.h> | |
#ifndef M_PI | |
#define M_PI 3.14159265358979323846264338327950288 | |
#endif | |
#define D_R (M_PI / 180.0) | |
const double EARTH_RADIUS_IN_METERS = 6372797.560856; |
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 Request : NSObject { | |
func send(url: String, f: (String)-> ()) { | |
var request = NSURLRequest(URL: NSURL(string: url)!) | |
var response: NSURLResponse? | |
var error: NSErrorPointer = nil | |
var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error: error) | |
var reply = NSString(data: data!, encoding: NSUTF8StringEncoding) | |
f(reply as! String) | |
} | |
} |
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 SwiftSingleton { | |
class var shared: SwiftSingleton { | |
return Inner.instance | |
} | |
struct Inner { | |
static let instance: SwiftSingleton = SwiftSingleton() | |
} | |
} |
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
The point at which the origin of the content view is offset from the origin of the scroll view | |
content view origin相对于scroll view origin的偏移 | |
可以把content view理解为设备屏幕,scroll view origin是要显示的内容 | |
显示内容下拉时content view origin 在 scroll view origin 上面, 此时contentOffset.y < 0, 这就是为什么下拉scroll view时contentOffset.y < 0 |
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
func randomInRange(range: Range<Int>) -> Int { | |
let count = UInt32(range.endIndex - range.startIndex) | |
return Int(arc4random_uniform(count)) + range.startIndex | |
} | |
for _ in 0...10 { | |
print(randomInRange(1...20)) | |
} |
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
// TargetName-Bridging-Header.h | |
#import <CommonCrypto/CommonCrypto.h> | |
// StringMD5.swift | |
extension String { | |
var MD5: String { | |
let cString = self.cStringUsingEncoding(NSUTF8StringEncoding) | |
let length = CUnsignedInt( | |
self.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) | |
) |
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
#!/bin/sh | |
# | |
# | |
if [ "$#" -ge 1 ]; then | |
LOG_DIR=$1 | |
else | |
LOG_DIR=/data/wwwroot/game_server/logs | |
fi |
OlderNewer