拍照有旋转角度,会导致直接存储变成90度
下面的是简单的解决方式,不太齐全,但可以参考图片处理功能
完整的做法参考这个比较好:
http://stackoverflow.com/q...

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info  
{  
    NSString *type = [info objectForKey:UIImagePickerControllerMediaType];  
    if ([type isEqualToString:@"public.image"]) {  
        UIImage* image=[info objectForKey:UIImagePickerControllerOriginalImage];  
        UIImageOrientation imageOrientation=image.imageOrientation;  
        if(imageOrientation!=UIImageOrientationUp)  
        {  
            // 原始图片可以根据照相时的角度来显示,但UIImage无法判定,于是出现获取的图片会向左转90度的现象。  
            // 以下为调整图片角度的部分  
            UIGraphicsBeginImageContext(image.size);  
            [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];  
            image = UIGraphicsGetImageFromCurrentImageContext();  
            UIGraphicsEndImageContext();  
            // 调整图片角度完毕  
        }  
        [picker dismissViewControllerAnimated:YES completion:nil];  
    }  
}  
苹果有介绍:

引用
-webkit-touch-callout
Disables the default callout shown when you touch and hold a touch target.

Syntax
-webkit-touch-callout: behavior;


可以在css里设定:

body{margin:0;padding:0;-webkit-touch-callout:none;}


或者在object-c里设置,在网页加载完成webViewDidFinishLoad时:

[webView stringByEvaluatingJavaScriptFromString:@"document.body.style.webkitTouchCallout='none';"];


前者适合自己控制的网页,不用改app,后者就适合所有的网页了。

https://developer.apple.co...
防范DDOS攻击脚本

#防止SYN攻击 轻量级预防
iptables -N syn-flood
iptables -A INPUT -p tcp --syn -j syn-flood
iptables -I syn-flood -p tcp -m limit --limit 3/s --limit-burst 6 -j RETURN
iptables -A syn-flood -j REJECT
#防止DOS太多连接进来,可以允许外网网卡每个IP最多15个初始连接,超过的丢弃
iptables -A INPUT -i eth0 -p tcp --syn -m connlimit --connlimit-above 15 -j DROP
iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT

#用Iptables抵御DDOS (参数与上相同)
iptables -A INPUT  -p tcp --syn -m limit --limit 12/s --limit-burst 24 -j ACCEPT
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT


##########################################################

防范CC攻击

当apache站点受到严重的cc攻击,我们可以用iptables来防止web服务器被CC攻击,实现自动屏蔽IP的功能。
1.系统要求
(1)LINUX 内核版本:2.6.9-42ELsmp或2.6.9-55ELsmp(其它内核版本需要重新编译内核,比较麻烦,但是也是可以实现的)。
(2)iptables版本:1.3.7
2. 安装
安装iptables1.3.7和系统内核版本对应的内核模块kernel-smp-modules-connlimit
3. 配置相应的iptables规则

示例如下:
(1)控制单个IP的最大并发连接数
iptables -I INPUT -p tcp --dport 80 -m connlimit  --connlimit-above 50 -j REJECT #允许单个IP的最大连接数为 30
#默认iptables模块不包含connlimit,需要自己单独编译加载,请参考该地址
http://sookk8.blog.51cto.com/455855/280372不编译内核加载connlimit模块

(2)控制单个IP在一定的时间(比如60秒)内允许新建立的连接数
iptables -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --update --seconds 60 --hitcount 30 -j REJECT iptables -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --set -j ACCEPT
#单个IP在60秒内只允许最多新建30个连接

4. 验证
(1)工具:flood_connect.c(用来模拟攻击)
(2)查看效果:
使用
watch 'netstat -an | grep:21 | grep<模拟攻击客户机的IP>| wc -l'

实时查看模拟攻击客户机建立起来的连接数,
使用
watch 'iptables -L -n -v | \grep<模拟攻击客户机的IP>'

查看模拟攻击客户机被 DROP 的数据包数。
5.注意
为了增强iptables防止CC攻击的能力,最好调整一下ipt_recent的参数如下:
#cat/etc/modprobe.conf options ipt_recent ip_list_tot=1000 ip_pkt_list_tot=60
#记录1000个IP地址,每个地址记录60个数据包 #modprobe ipt_recent

参考自: http://sookk8.blog.51cto.com/455855/321242/
没有与时俱进,发现从ios5以来,居然不知道怎么处理旋转控制了

首先,appdelegate里面可以控制全局的,比如控制ipad随便转,iphone不转:

- (NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        // iPad
        return UIInterfaceOrientationMaskAll;
    } else {
        // iPhone / iPod Touch
        return UIInterfaceOrientationMaskPortrait;
    }
    
}


其次,如果需要每个去控制,可以是这样:

How to support one or more landscape controllers in app that is portrait mainly in ios6:

1) in AppDelegate

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
    {
        UINavigationController* ns = (UINavigationController*)self.window.rootViewController;
        if (ns) {
            UIViewController* vc = [ns visibleViewController];
//by this UIViewController that needs landscape is identified
            if ([vc respondsToSelector:@selector(needIos6Landscape)])
                return [vc supportedInterfaceOrientations];

        }
        return UIInterfaceOrientationMaskPortrait; //return default value
    }


2) in UIView controller(s) that needs landscape (or portrait+lanscape etc):

//flag method
-(void)needIos6Landscape {
}
- (BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskAllButUpsideDown;
}


3) in controllers, to which you can RETURN from controllers, that can be rotated in landscape - this is important, otherwise they remaind landscape on return from landscape-enabled VC.

- (BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    return UIInterfaceOrientationMaskPortrait;
}


4) (maybe not needed, but for sure..) - subclass navigation controller(s) you using, and add:

- (BOOL)shouldAutorotate
{
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
    UIViewController* vc = [self visibleViewController];
    if (vc) {
        if ([vc respondsToSelector:@selector(needIos6Landscape)]) {
             return [vc supportedInterfaceOrientations];
        }
    }
    return UIInterfaceOrientationMaskPortrait;
}


The important step is to ask for orientation only controllers from your app, because during transition between controllers, for some time there is some system controller as root, and will return incorrect value (this took me 2 hrs to find out, it was reason it was not working).

引自:http://stackoverflow.com/q...
service postfix start
Starting postfix:                                          [FAILED]


今天启动一个新服务器的postfix,一直都提示失败
重新安装也没用,也没有错误输出

检查postfix命令:
which postfix
/usr/sbin/postfix

执行看看:
# /usr/sbin/postfix
postfix: fatal: parameter inet_interfaces: no local interface found for ::1

编辑配置文件
# vi /etc/postfix/main.cf
把 inet_interfaces 设置为 all

再次启动:
# service postfix start
Starting postfix:                                          [  OK  ]
分页: 5/133 第一页 上页 1 2 3 4 5 6 7 8 9 10 下页 最后页 [ 显示模式: 摘要 | 列表 ]

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐