Skip to content

Instantly share code, notes, and snippets.

View weekwood's full-sized avatar
๐ŸŽฏ
Focusing

Di Wu weekwood

๐ŸŽฏ
Focusing
View GitHub Profile
const double a = 6378245.0;
const double ee = 0.00669342162296594323;
static BOOL outOfChina(double lat, double lon){
if(lon < 72.004 || lon > 137.8347){
return true;
}
if(lat < 0.8293 || lat > 55.8271){
return true;
@weekwood
weekwood / alpha.m
Created October 12, 2013 17:39
Snippet
switch (scope) {
case 0:
if (maskTime >= 0) {
// ๆ—ฅๅ‡บ
if (_ispanGesture) {
_imageLayer0.alpha = ((float)(perTime - abs(maskTime)))/perTime;
_imageLayer1.alpha = 1;
}else{
[self setimageLayer:_imageLayer0 byAlpha:((float)(perTime - abs(maskTime)))/perTime];
[self setimageLayer:_imageLayer1 byAlpha:1];
<!DOCTYPE html>
<html lang="en-US" prefix="og: http://ogp.me/ns#">
<head>
<meta charset="utf-8">
<title>{% if is_home %}{{ site.author }}{% elif is_post %}{{ post.title }}{% elif is_link %}{{ link.title }}{% elif is_page %}{{ page.title }}{% endif %} | {{ site.name }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
NSFileManager *fileManager = [NSFileManager defaultManager];
NSError *error;
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *documentDBFolderPath = [documentsDirectory stringByAppendingPathComponent:@"templates"];
NSString *resourceDBFolderPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"templates"];
if (![fileManager fileExistsAtPath:documentDBFolderPath]) {
//Create Directory!
[fileManager createDirectoryAtPath:documentDBFolderPath withIntermediateDirectories:NO attributes:nil error:&error];
{ "channel" : 1,
"content" : "์šฐ๋ฆฌ ์ฃผ๋ณ€์˜ ๋‹ค์–‘ํ•œ ์‚ฌ๋žŒ๋“ค์˜ ์‚ถ์„ ์ง„์†”ํ•˜๊ฒŒ ๋ณด์—ฌ์ฃผ๋Š” ๋‹คํ๋ฉ˜ํ„ฐ๋ฆฌ๋กœ 2001๋…„ 2์›” 13์ผ์— ์ฒซ ๋ฐฉ์†ก์„ ์‹œ์ž‘ํ•ด์„œ ์›”์š”์ผ๋ถ€ํ„ฐ ๊ธˆ์š”์ผ๊นŒ์ง€ ๋งค์ผ ๋ฐฉ์†ก์„ ํ•˜๊ณ  ์žˆ๋Š” ์žฅ์ˆ˜ ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค. ๋‹ค์–‘ํ•œ ์‚ฌ๋žŒ๋“ค์˜ ๋งค์šฐ ์ง„์†”ํ•œ ๋ชจ์Šต์„ ๋‹ด์•„๋‚ด๋Š” ๊ฒƒ์ด ํŠน์ง•์ด๋‹ค. ใ€Š์ธ๊ฐ„๊ทน์žฅใ€‹์€ ๋งค์ฃผ ์›” ~ ๊ธˆ ์•„์นจ 7์‹œ 50๋ถ„์—์„œ 8์‹œ 25๋ถ„๊นŒ์ง€ KBS ์ œ1TV์—์„œ ๋ฐฉ์†ก๋˜๊ณ  ์žˆ๋Š” ํ…”๋ ˆ๋น„์ „ ํ”„๋กœ๊ทธ๋žจ์ด๋‹ค. 2000๋…„ 5์›” 1์ผ์— ๋ฐฉ์†ก์„ ์‹œ์ž‘ํ•˜์—ฌ ํ˜„์žฌ๊นŒ์ง€ ๋ฐฉ์†ก๋˜๊ณ  ์žˆ๋‹ค.",
"cover_img" : "http://tv1009.anydev.net/uploads/tv_info/2013072410074133367.jpg",
"create_time" : "2013-07-17 18:53:56",
"hit" : 2040,
"hour_minute" : 28200,
"id" : 472,
"is_over" : 0,
"last_term" : "20140327",
"last_update" : 1395923383,
NSMutableArray *resultArray = [NSMutableArray new];
NSArray *groups = [self.survey.questions valueForKeyPath:@"@distinctUnionOfObjects.type"];
for (NSString *groupId in groups)
{
NSMutableDictionary *entry = [NSMutableDictionary new];
[entry setObject:groupId forKey:@"type"];
NSArray *groupNames = [self.survey.questions filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"type = %@", groupId]];
[entry setObject:groupNames forKey:@"values"];
@weekwood
weekwood / thumbnail.m
Last active August 29, 2015 14:09
AVURLAsset Thumbnail
AVURLAsset *asset1 = [[AVURLAsset alloc] initWithURL:[info objectForKey:@"UIImagePickerControllerMediaURL"] options:nil];
AVAssetImageGenerator *generate1 = [[AVAssetImageGenerator alloc] initWithAsset:asset1];
generate1.appliesPreferredTrackTransform = YES;
NSError *err = NULL;
CMTime time = CMTimeMake(1, 2);
CGImageRef oneRef = [generate1 copyCGImageAtTime:time actualTime:NULL error:&err];
UIImage *one = [[UIImage alloc] initWithCGImage:oneRef];
_MimeTypes = @{
@"text/plain": @{ @"icon": @"txt-big", @"ext" : @[@"txt", @"text", @"conf", @"def", @"log", @"list", @"ini"] },
@"text/css": @{ @"icon": @"css-big", @"ext" : @[@"css"] },
@"text/javascript": @{ @"icon": @"js-big", @"ext" : @[@"js"] },
@"text/html": @{ @"icon": @"ie-big", @"ext" : @[@"html", @"htm"] },
@"text/xml": @{ @"icon": @"xml-big", @"ext" : @[@"xml", @"xsl", @"xslt"] },
@"text/csv": @{ @"icon": @"csv-big", @"ext" : @[@"csv"] },
@"text/x-vcard": @{ @"icon": @"vcf-big", @"ext" : @[@"vcf"] },
@"text/calendar":
static NSDictionary *titleMapping = nil;
if (!titleMapping) {
NSString *(^const format)(NSUInteger, NSString *, NSString *) = ^(NSUInteger value, NSString *singular, NSString *plural) {
return [NSString stringWithFormat:@"%d %@", value, (value == 1 ? singular : plural)];
};
titleMapping = @{
@"Scratches" : ^(MyClass *target) {
return format([target numberOfScratches], @"Scratch", @"Scratches");
},
{
data={
cards=({
"_id"=549f70766b0760c934a07df2;"comment_count"=2;cover="http://img.iyuanzi.net/cardCover/2014-12/b23ebe43-27b1-4941-8838-aa2ce9691d34";"create_at"="1\U4e2a\U6708\U524d";description="";"favorite_count"=4;id=549f70766b0760c934a07df2;index=0;isFavorited=0;isPraised=0;isTop=1;owner={
"_id"=549d1d2e566d41e412eef816;avatar="http://img.iyuanzi.net/userAvatar/2014-12/d5cb4c03-10ff-45d2-adbd-5871e724898e";id=549d1d2e566d41e412eef816;"nick_name"="\U852c\U83dc\U5988\U5988";
};"praise_count"=10;"shared_count"=4;title="\U7ed9\U7238\U7238\U7684\U543b";"update_at"="16\U5929\U524d";
},
{
"_id"=549f70736b0760c934a07dec;"comment_count"=4;cover="http://img.iyuanzi.net/cardCover/2014-12/8657281e-978f-470f-92c0-7f7a8ab926fb";"create_at"="1\U4e2a\U6708\U524d";description="";"favorite_count"=2;id=549f70736b0760c934a07dec;index=0;isFavorited=0;isPraised=0;isTop=1;owner={
"_id"=549d1d2e566d41e412eef816;avatar="http://img.iyuanzi.net/userAvatar/2014-12/d5cb4c03-10ff-45d2-adbd-5871e724898e";id=