#define radians(degrees) (degrees * M_PI/180)
UIImage *rotate(UIImage *image) {
CGSize size = image.size;;
UIGraphicsBeginImageContext(size);
CGContextRef context = UIGraphicsGetCurrentContext();
// If this is commented out, image is returned as it is.
CGContextRotateCTM (context, radians(90));
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
Run Code Online (Sandbox Code Playgroud)
还有别的错吗?出于想法.
如何发出不包含标题字段的请求?请求从头开始发送到我自己的服务器实现,这不关心头字段.该请求最多只包含一个帖子正文.如果我错过了一些合乎逻辑的东西,请告诉我.
请不要告诉我有关ASIHTTPRequest的信息.谢谢.
在Ruby中,Process.setsid如果以非超级用户身份运行,则调用失败,并显示“不允许操作”错误。尝试:
$ irb
irb(main):001:0> Process.setsid
Errno::EPERM: Operation not permitted
from (irb):1:in `setsid'
from (irb):1
from ~/.rbenv/versions/1.9.2-p290/bin/irb:12:in `<main>'
Run Code Online (Sandbox Code Playgroud)
或者,如果我更改uid或使用Process.uid=method 的进程,它将失败,并显示相同的错误。如果我以root身份运行Ruby程序,则效果很好,并且在运行时不更改进程的UID。
但是,在Ubuntu或其他发行版的Shell中,setsid(参考:http : //linux.die.net/man/2/setsid)程序不需要超级用户特权。
我知道这会stdsid重置程序的会话,这在守护进程时也很有用。在我的代码中,我试图更改UID并对其进行守护进程,同时还要重置会话。
因此,我很好奇为什么Process.setsid需要上述特权,而setsid大多数UNIX(如OS)上的程序却不需要。