手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆
浏览模式: 标准 | 列表2012年03月的文章

几个有用的网站链接

我日,写了半天就没了。。。

1、http://www.colorzilla.com/gradient-editor/
     A powerful Photoshop-like CSS gradient editor from ColorZilla.

2、http://www.speich.net/articles/2010/07/27/how-to-create-php-documentation-in-phpstorm/
    如何配置phpstorm中的phpdoc

3、http://www.ibm.com/developerworks/cn/aix/library/es-unix-perfmonsar.html
    http://www.cnblogs.com/jackyrong/archive/2008/08/02/1258835.html
这两天我的VPS经常CPU过高,11爷推荐我说用Sar,由于不清楚sar,所以找了点资料,上面的URL是我找的,下面的是11爷给推荐的

4、 http://www.cnblogs.com/stephen-liu74/archive/2012/03/28/2357783.html
http://blog.nosqlfan.com/html/2942.html
http://www.cnblogs.com/stephen-liu74/archive/2012/03/26/2356951.html
   Redis 相关资料

5、http://www.myhack58.com/Article/html/3/62/2012/32870.htm
     http://www.linuxde.net/2011/11/1953.html
这两个URL是防范http trace攻击的

6、http://jsfiddle.net/k5VET/
http://www.zhangxinxu.com/study/200909/text-overflow-ellipsis-so-on.html
关于文字内容溢出用点点点(...)省略号表示
-------
暂时只放这么多。。。

让CRONTAB精确到秒的执行任务

众所周知,crontab的最小粒度是分,即当第一位是“*/1”时,即最小单位是每分钟执行。
但是,有时候我们要按秒执行,当然这是比较夸张的了,但每半分钟执行一次还是有可能的,这时候就没有办法了,所以后 来 找啊找,就找到了一篇说明:

XML/HTML代码
  1. */1 * * * * sh /root/cron.sh  
  2. */1 * * * * sleep 30 && sh /root/cron.sh  

执行的时候先sleep 30秒,变相的达到每半分钟执行此命令,果然很变态

windows下面也有模拟crontab的软件,如crontabs,pycrontab等,都是注册成一个服务,然后再执行,但是没有一个软件是比较好用的。总有小问题。

Tags: crontab

一段无聊的代码[多行自动截取字符并加上...]

一段未优化过的无聊JS代码,暂时不优化了,以实现为主:

XML/HTML代码
  1. <style type="text/css">.zxx_text_overflow_6{ width:100px; height:100px; border:1px solid #CCC; }</style>  
  2. <div class="zxx_text_overflow_6">  
  3.     <img src="i.png" alt="" style="float:right;width:50px;" />  
  4.     <p>你个杀千刀的,怎么写了这么多的文字,我要被拦腰截。断了啊,kitty救我!你个杀千刀的,怎么写了这么多的文字,我要被拦腰截断了啊,kitty救我!你个杀千刀的,怎么写了这么多的文字,我要被拦腰截断了啊,kitty救我!你个杀千刀的,怎么写了这么多的文字,我要被拦腰截断了啊,kitty救我!你个杀千刀的,怎么写了这么多的文字,我要被拦腰截断了啊,kitty救我!</p>  
  5. </div>  
  6. <script type="text/javascript">  
  7.     String.prototype.strtoarray=function (){  
  8.         var t=[], b=/(\s*[\S\u00ad]+\s*)/g, f='';  
  9.         for(i=0; i<this.length; i++){  
  10.             c=this.charCodeAt(i);  
  11.             t.push(c>128?" "+this.charAt(i):this.charAt(i));//p += c < 128 ? 1 : (c < 2048 ? 2 : (c < 65536 ? 3 : 4));  
  12.         }  
  13.         //s = t.join("").split(b);  
  14.         return t.join("").split(b).join("Ω").replace(/ΩΩ/g,"Ω").split("Ω");  //这一段其实挺有意思,理论上,上一句就OK了,但事实上这一句才正常。。。好吧。
  15.         //    return s;  
  16.     }  
  17.     var t = +new Date();   
  18.     var d=document.querySelector(".zxx_text_overflow_6");  
  19.     var p=document.querySelector(".zxx_text_overflow_6 p");  
  20.     var pInfo = getComputedStyle(p);  
  21.     var s=p.innerHTML.strtoarray();  
  22.     var pData = [];  
  23.     p.innerHTML='';  
  24.     for(var i=0; i<s.length; i++){  
  25.         p.innerHTML+=s[i];  
  26.         pData.push(s[i]);  
  27.         if((p.offsetHeight+parseInt(pInfo.marginTop)+parseInt(pInfo.paddingTop))>= d.offsetHeight){  
  28.             if(s[i-1]!="。"||s[i-1]!='.'){  
  29.                 p.innerHTML = pData.slice(0,-2).join("")+ "...";  
  30.             }else{  
  31.                 p.innerHTML = pData.slice(0,-1).join("");  
  32.             }  
  33.             break;  
  34.         }  
  35.     }  
  36.     alert("执行时间" +((+new Date()) - t )/ 1000 + "秒");  
  37. </script>  

效果如下:
大小: 14.12 K
尺寸: 139 x 129
浏览: 2047 次
点击打开新窗口浏览全图

转:蛋疼的版本提交日志TOP10

10. XXXX项目-改版 // 你用一次也就罢了,需要整个项目期间提交的日志都是这句话嘛...

 9. 修改         // 如果版本提交不是做修改,莫非骗提交率来了?

 8. BUG修改      // 是不是还要先提交一个版本叫做“BUG生成”?

 7. 修改BUG      // LS的,猿粪呐!~

 6. 测试         // 册那...

 5. test        // 猿粪,又见猿粪

 4. 版本更新     // 俺又不是siri,发出这种让人产生联想的指令干嘛,讨厌~

 3. update      // 你就算说英文俺也变不成siri

 2. publish     // 小样,会的词还挺多啊!

 1. svn         // 靠.......

---------

挺有意思,不过,我大部分还是习惯将主要更新内容扔上去,但如果一次上传过多的时候就没办法写了。一个一个的上传也不是个办法。。。

Tags: svn

IOS不再允许使用UDID

上面一则新闻来自macx,原文地址是:http://www.macx.cn/thread-2041511-1-1.html
iOS设备的设备唯一识别码UDID(unique device identifier),顾名思义就是每个设备只有这一个标识符,与设备硬件相关,是无法更改的。根据报道苹果从本周开始已经开始禁止第三方应用程序使用 iOS设备的UDID,并指出苹果将在下周开始加强设备UDID的隐私保护。

在iOS 5条款中,苹果已经对开发者进行了提醒,使用用户设备UDID是不赞成的并将逐步取缔这一做法。消息称苹果的十个App审核团队中已经有两个开始禁止使用UDID的应用通过审核了,据说下周将增加到四个。

一些第三方开发者表示,如果苹果有明确禁止使用UDID的条款颁布,那他们会按照新标准执行,不过他们还希望看看未来的形式如何发展。无论是开发者还是广告商都将受到新政策的严重影响。

苹果最近被隐私问题腿上风口浪尖,美国国会也几次三番要求苹果解释隐私保护问题,苹果可能也是出于外接压力才进一步紧缩iOS条款的。

如何查看自己iOS设备的UDID:
将设备链接到电脑iTunes,本机信息原来显示序列号的地方点击一下,即可看到标示符UDID信息
----------------
基于上述新闻,于是就有了下面这篇文章,嗯,当然也不是我写的,原文地址是:http://pingguohe.net/2011/08/25/uuid_after_ios5/

iOS5已经发布了6个beta版,除了在用户体验上的提升,对于开发者来说也有很多变化,最大的莫过于对UDID的限制访问。在之前的iOS应用 中,我们一般使用UDID来标记一个用户,基于UUID建立用户数据库。现在,安装了iOS5 beta 6的设备上已经取不到UDID,[UIDevice uniqueIdentifier] 只能返回一个“5.0”了。

取代被禁用的iOS UDID,其实有很多方法,比如,有人建议使用网卡mac,但我不建议使用这种方法,mac地址属于用户隐私数据,我想如果你试图获取用户mac并上传,review通不过。

官方给出的建议是CFUUID:

An alphanumeric string unique to each device based on various hardware details. (read-only) (Deprecated in iOS 5.0. Instead, create a unique identifier specific to your app.)

@property (nonatomic, readonly, retain) NSString *uniqueIdentifier
Special Considerations

Do not use the uniqueIdentifier property. To create a unique identifier specific to your app, you can call the CFUUIDCreate function to create a UUID, and write it to the defaults database using the NSUserDefaults class.

通过CFUUIDCreate创建一个CFUUID对象,存入NSUserDefaults,作为用户身份的唯一标示。

官方对CFUUID对象的解释如下:

CFUUID objects are used by plug-ins to uniquely identify types, interfaces, and factories. When creating a new type, host developers must generate UUIDs to identify the type as well as its interfaces and factories.

UUIDs (Universally Unique Identifiers), also known as GUIDs (Globally Unique Identifiers) or IIDs (Interface Identifiers), are 128-bit values guaranteed to be unique. A UUID is made unique over both space and time by combining a value unique to the computer on which it was generated—usually the Ethernet hardware address—and a value representing the number of 100-nanosecond intervals since October 15, 1582 at 00:00:00.

The standard format for UUIDs represented in ASCII is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067. The hex representation looks, as you might expect, like a list of numerical values preceded by 0x. For example, 0xD7, 0x36, 0x95, 0x0A, 0x4D, 0x6E, 0x12, 0x26, 0x80, 0x3A, 0x00, 0x50, 0xE4, 0xC0, 0x00, 0x67 . To use a UUID, you simply create it and then copy the resulting strings into your header and C language source files. Because a UUID is expressed simply as an array of bytes, there are no endianness considerations for different platforms.

可以看到CFUUID就是对GUID的一种封装,提供了创建方法和各种各种格式转换的方法。

以下代码是我对CFUUID和NSUserDefaults的封装,可以作为唯一标识来使用。

C++代码
  1. //  
  2. //  NewUUID.h  
  3. //  
  4. //  Created by jiajun.gao jiajun.gao on 8/25/11.  
  5. //   
  6. //  Create a UUID by self.  
  7. //  
  8. //  Call like this:  
  9. //  
  10. //    String *iNeedUUID = [NewUUID identifier];  
  11. //  
  12.    
  13. #define NEW_UUID_KEY    @"uuid_created_by_developer"  
  14.    
  15. @interface NewUUID : NSObject {  
  16.    
  17.     NSString *uuid;  
  18.    
  19. }  
  20.    
  21. + (NSString *)identifier;  
  22.    
  23. @property (nonatomic, retain) NSString *uuid;  
  24.    
  25. @end  

NewUUID.m

C++代码
  1. #import <Foundation/Foundation.h>  
  2.    
  3. #import "NewUUID.h"  
  4.    
  5. @implementation NewUUID  
  6.    
  7. @synthesize uuid;  
  8.    
  9. - (id)init {  
  10.     self = [super init];  
  11.     if (self) {  
  12.         uuid = NULL;  
  13.         return self;  
  14.     }  
  15.    
  16.     return nil;  
  17. }  
  18.    
  19. + (id)_instance {  
  20.     static id obj = nil;  
  21.     if( nil == obj ) {  
  22.         obj = [[self alloc] init];  
  23.     }  
  24.    
  25.     return obj;  
  26. }  
  27.    
  28. + (NSString *)identifier {  
  29.    
  30.     NSUserDefaults *handler = [NSUserDefaults standardUserDefaults];  
  31.     [[NewUUID _instance] setUuid:[NSString stringWithFormat:@"%@", [handler objectForKey:NEW_UUID_KEY]]];  
  32.    
  33.     if (NULL == [[NewUUID _instance] uuid] || 46 > [[[NewUUID _instance] uuid] length]) {  
  34.    
  35.         CFUUIDRef uuid = CFUUIDCreate(NULL);  
  36.         CFStringRef uuidStr = CFUUIDCreateString(NULL, uuid);  
  37.    
  38.         NSString *result = [NSString stringWithFormat:@"%@-%@", @"new-uuid-", uuidStr];  
  39.    
  40.         CFRelease(uuidStr);  
  41.         CFRelease(uuid);  
  42.    
  43.         [[NewUUID _instance] setUuid:result];  
  44.    
  45.    
  46.         [handler setObject:[[NewUUID _instance] uuid] forKey:NEW_UUID_KEY];  
  47.         [handler synchronize];  
  48.     }  
  49.    
  50.     return [[NewUUID _instance] uuid];  
  51. }  
  52.    
  53. @end  

 

 

 

Tags: ios, udid

Records:30123456