Skip to content

Instantly share code, notes, and snippets.

Jason Han phnessu4

Block or report user

Report or block phnessu4

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ObservableType+compose.swift
struct ComposeTransformer<T, R> {
let transformer: (Observable<T>) -> Observable<R>
init(transformer: @escaping (Observable<T>) -> Observable<R>) {
self.transformer = transformer
}
func call(_ observable: Observable<T>) -> Observable<R> {
return transformer(observable)
}
}
View gist:8a8e6b5589c9b2e94fb12b0a1baea134
按照2个人标准,最多四套房计算。
var basePersonCount = 2;
var basePersonArea = 80;
var houses = [
{area:160, money:30000},
{area:90, money:30000},
];
var totalArea = (numOfHouse = 1)=>{
var totalArea = 0;
View Xcode 文件下载.md

在 Xcode 里下载文件真的是一种折磨, 特别是每次 Xcode 大版本更新都会遇到新的下载内容. 经过一翻周折, 本人找到一个方法可以轻松快速便捷地下载和安装对应的 Simulator 和 Doc 文件

  1. 在 Mac 下, 打开 Xcode, 进入 Preference 中的 Downloads 面板
  2. 点击任意的下载按钮
  3. 打开系统帮助工具 Console
  4. 稍等一会儿, 在 Xcode 里取消下载, 然后你会在 Console 里面看到对应的下载地址 (对应的 Cosnole Message 是 (DVTDownloadable: Download Cancelled. Downloadable: ...) 之类的)
  5. 复制对应的链接地址, 到某雷或者任何比 Xcode 下载快的工具里
  6. 等待下载完成, 进入 /Users/#{Username}/Library/Caches
@phnessu4
phnessu4 / class.cpp
Last active Jul 1, 2016
clang rewrite-objc
View class.cpp
#ifndef __OBJC2__
#define __OBJC2__
#endif
struct objc_selector; struct objc_class;
struct __rw_objc_super {
struct objc_object *object;
struct objc_object *superClass;
__rw_objc_super(struct objc_object *o, struct objc_object *s) : object(o), superClass(s) {}
};
#ifndef _REWRITER_typedef_Protocol
View .env.development
APP_ENV=development
APP_DEBUG=true
APP_KEY=SomeRandomString
APP_URL=http://beta.domain
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
View gist:1475e9b9c4f6640ac236
@interface UIImage (Utility)
+ (UIImage *)imageFromColor:(UIColor *)color;
-(UIImage *) getSubImage:(CGRect)rect;
-(UIImage *)scaleToSize:(CGSize)size;
+ (UIImage *)TransformtoSize:(CGSize)size image:(UIImage *)image;
- (UIImage *)imageWithMaxLength:(CGFloat)sideLenght;
View gist:4cac9224c94b2bdd01d1
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);
NSString *ourDocumentPath =[documentPaths objectAtIndex:0];
NSString * filepath = [ourDocumentPath stringByAppendingString:[NSString stringWithFormat:@"image%lu.png",(unsigned long)index]];
// [fileManager createDirectoryAtPath:filepath withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createFileAtPath:filepath
contents:UIImagePNGRepresentation(image)
attributes:nil];
NSLog(@"-------file %@",filepath);
@phnessu4
phnessu4 / wwdc2014
Last active Jan 19, 2020
wwdc 2014 sessions and pdf
View wwdc2014
pdf
http://devstreaming.apple.com/videos/wwdc/2014/102xxw2o82y78a4/102/102_platforms_state_of_the_union.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/201xx2xfazhzce8/201/201_advanced_topics_in_internationalization.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/202xx3ane09vxdz/202/202_whats_new_in_cocoa_touch.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/203xxh9oqtm0piw/203/203_introducing_healthkit.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/204xxhe1lli87dm/204/204_whats_new_in_cocoa.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/205xxqzduadzo14/205/205_creating_extensions_for_ios_and_os_x,_part_1.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/206xxdiurnffagr/206/206_introducing_the_modern_webkit_api.pdf?dl=1
http://devstreaming.apple.com/videos/wwdc/2014/207xx270npvffao/207/207_accessibility_on_os_x.pdf?dl=1
View gist:6a5301d1518bde913575
多线程下载请安装axel (brew install axel)
PDFs:
curl https://developer.apple.com/videos/wwdc/2014/ | grep -ioI 'http.*pdf?dl=1' | sed 's/\?dl=1//g' | xargs -n1 axel -a -n 4
Videos:
curl https://developer.apple.com/videos/wwdc/2014/ | grep -ioI 'http.*._hd_.*dl=1">HD' | sed -e 's/\?dl=1">HD//g'| xargs -n1 axel -a -n 8
You can’t perform that action at this time.