This file contains hidden or 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
- (void)drawRect:(CGRect) rect { | |
// If you plan to do more drawing later, it's a good idea | |
// to save the graphics state before clipping. | |
[NSGraphicsContext saveGraphicsState]; | |
long r = random(); | |
long g = random(); | |
long b = random(); | |
NSColor *color = [NSColor colorWithRed: (r * 1.0/(r + g + b)) green: (g * 1.0 / (r + g + b)) blue: (b * 1.0 / (r + g + b)) alpha: 1.0]; |
This file contains hidden or 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
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url]; | |
[req setHTTPMethod:@"POST"]; // POST 请求 | |
[req setValue: [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundry] forHTTPHeaderField:@"Content-Type"]; //boundry = 0xKhTmLbOuNdArY;可参考 HTTP 协议 | |
[req setValue: @"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36" forHTTPHeaderField: @"User-Agent"]; | |
NSMutableData *postData = [NSMutableData dataWithCapacity:[data length] + 512]; | |
[postData appendData: [[NSString stringWithFormat:@"--%@\r\n", boundry] dataUsingEncoding:NSUTF8StringEncoding]]; | |
[postData appendData: [[NSString stringWithFormat: @"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n\r\n", FORM_FLE_INPUT, filename] dataUsingEncoding:NSUTF8StringEncoding]]; // FORM_FLE_INPUT 类似与 <input type="file" name="xxx"> 中的 name 属性值,用来在服务端获取上传的文件,比如 $_FILES['xxx'] |
This file contains hidden or 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
var extend = function(a, b) { | |
for (var i in b) | |
a[i] = b[i]; | |
return a; | |
}; | |
var fluent = function(f) { | |
return function() { | |
var clone = extend(Object.create(null), this); | |
f.apply(clone, arguments); |
This file contains hidden or 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
function! Strcmp(...) | |
let a1 = a:1 | |
let a2 = a:2 | |
if a1 =~ '^\d\+$' | |
let a1 = 0 + a1 | |
endif | |
if a2 =~ '^\d\+$' | |
let a2 = 0 + a2 | |
endif |
This file contains hidden or 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
fis.set('namespace', 'common'); | |
//-- system settings | |
fis.set('server', { | |
'libs': 'pc', | |
}); | |
fis.set('plugin less', { |
This file contains hidden or 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
// | |
// Tiny calculator | |
// | |
// cal := modules.NewCal() | |
// fmt.Println(cal.MustCal("1x1+4/2x(1+2)")) | |
// result, err := cal.Cal("1x1+4/2x(1+2)") | |
// fmt.Println(cal.GetPostfixExpr("1x1+4/2x(1+2)")) | |
// | |
package modules |
诚然,为了开发的便利高效,不得不用并行开发的方式--后端开发和前端开发并行开发,这时候问题就来了。对于一个同样的项目,并行开发如何拆分比较容易实现并达到真正的高效,我们在此处选择了以模板为分界点,数据为桥的开发方式。
前端开发人员负责模板及其周边的静态资源的开发工作,而后端和前端逻辑用数据作为桥梁进行串接,在这样一种开发模式下开发起初只需要制定好数据规则就可以愉快的进行开发了。
在前端这块,为了能畅通的使用这些数据进行开发,不得不进行本地模拟线上环境,使用模拟数据进行渲染,而恰巧需要一个便捷的本地server
来充当服务器的角色。这篇讲述一下这个server
的方方面面。
server
呢可以选择比较时髦的nginx
、lighttpd
、apache
等,当然fis已经集成了若干解析后端脚本的服务。