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

推荐密码管理软件: KeePass

KeePass Password Safe 2,这款软件是同事在用的,看他使用的时候,我觉得还不错,所以就向他找了一份,并尝试着使用了一下,觉得还是感觉不错的,所以用来推荐一下

Keepass有着自己的数据格式,至于能不能被其他软件所破解,就不是我关心的了(不可能说永远不可能破解,只是机率会比较小一点吧)

Keepass打开数据库时,可以指定密码,有三种方式1、密码,2、密码文件3、windows自身的用户

由于我用金山快盘,所以我就每天在单位和家里进行同步喽。使用起来也算方便,也能够自己按照自己的规定生成密码,有一个好处就是可以设定双击复制密码的时候在剪贴板里存放多少时间 ,超过这个时间后就自动被清空,这相对会让人感觉比较安全。

再说一下,这个软件也有很多的插件,比较感觉不错的会有两个插件是我想用的,kefromff,和sync,一个是可以把firefox里存放的密码导入到keepass里,另一个就是帮你把数据库备份啦 。。

其实还有一些插件,比如自动输入密码这个功能,我是觉得不太方便,因为他有顺序要设定,不能根据当初的设定而自动输入(如果顺序不对,就输的不对,我觉得太麻烦了)

当然,作为一个优秀的软件,它还是有汉化包的,所以,对于普通用户来说没有什么难度啦:http://keepass.info/ , 插件地址在:http://keepass.info/plugins.html , 插件地址是:http://keepass.info/translations.html。

以前好象有一个叫roboForm之类的软件,也用过一阵子,不过相对来说,用了这个软件后,我好象就忘了roboForm,不过那个软件好象是支持自动填表的。。而且相对比较准确(firefox也是可以的)

Tags: keepass

Yii:relations update(self::STAT)

今天在群里有朋友问我yii的relations的问题,结果贴出来的代码居然是类似这样的:

PHP代码
  1. function relations(){  
  2.     return array(  
  3.         'xx'=>array(self::STAT,'aa','aa_id')  
  4.     );  
  5. }  

我当时直接了当的对他说,错了,怎么可能会有self::STAT呢?只有has_many,has_one,belongs_to,many_many,stat是错的。结果他回答说我OUT了,STAT是新加入的。。。

于是欣欣然跑到YII的官网查看了一下GUIDE,果然在 Relational Active Record,一节中发现了这个Statistical Query

官方怎么说来着?第一句就让我大吃一惊:

Note: Statistical query has been supported since version 1.0.4.

奇怪,以前怎么没注意?

Besides the relational query described above, Yii also supports the so-called statistical query (or aggregational query). It refers to retrieving the aggregational information about the related objects, such as the number of comments for each post, the average rating for each product, etc. Statistical query can only be performed for objects related in HAS_MANY (e.g. a post has many comments) or MANY_MANY (e.g. a post belongs to many categories and a category has many posts).

Performing statistical query is very similar to performing relation query as we described before. We first need to declare the statistical query in the relations() method of CActiveRecord like we do with relational query.

PHP代码
  1. class Post extends CActiveRecord  
  2. {  
  3.     public function relations()  
  4.     {  
  5.         return array(  
  6.             'commentCount'=>array(self::STAT, 'Comment''post_id'),  
  7.             'categoryCount'=>array(self::STAT, 'Category''post_category(post_id, category_id)'),  
  8.         );  
  9.     }  
  10. }  

In the above, we declare two statistical queries: commentCount calculates the number of comments belonging to a post, and categoryCount calculates the number of categories that a post belongs to. Note that the relationship between Post and Comment is HAS_MANY, while the relationship between Post and Category is MANY_MANY (with the joining table post_category). As we can see, the declaration is very similar to those relations we described in earlier subsections. The only difference is that the relation type is STAT here.

With the above declaration, we can retrieve the number of comments for a post using the expression $post->commentCount. When we access this property for the first time, a SQL statement will be executed implicitly to retrieve the corresponding result. As we already know, this is the so-called lazy loading approach. We can also use the eager loading approach if we need to determine the comment count for multiple posts:

PHP代码
  1. $posts=Post::model()->with('commentCount''categoryCount')->findAll();  

The above statement will execute three SQLs to bring back all posts together with their comment counts and category counts. Using the lazy loading approach, we would end up with 2*N+1 SQL queries if there are N posts.

By default, a statistical query will calculate the COUNT expression (and thus the comment count and category count in the above example). We can customize it by specifying additional options when we declare it in relations(). The available options are summarized as below.

  • select: the statistical expression. Defaults to COUNT(*), meaning the count of child objects.

  • defaultValue: the value to be assigned to those records that do not receive a statistical query result. For example, if a post does not have any comments, its commentCount would receive this value. The default value for this option is 0.

  • condition: the WHERE clause. It defaults to empty.

  • params: the parameters to be bound to the generated SQL statement. This should be given as an array of name-value pairs.

  • order: the ORDER BY clause. It defaults to empty.

  • group: the GROUP BY clause. It defaults to empty.

  • having: the HAVING clause. It defaults to empty.

关键的是看最后这几个条件,可以让你知道这些参数如何配置。。。
官方的GUIDE地址:http://www.yiiframework.com/doc/guide/1.1/en/database.arr

Tags: yii, relations, stat, static query

意外:财经朗闲评又复出了?

这,纯粹是一篇废话连篇的博客
主要是因为晚上在看第一财经的时候,看到郎咸平在那里聊天,然后是说节目的名称是财经郎闲评。
依稀记得几年前这个节目就是在财经频道的,然后突然就消失了,然后就是爆出了上海的社保基金挪用案。
郎咸平这几年写了不少书,说了不少话,也分析过一些企业,使得一些企业被咔嚓了。
有人恨,有人爱。我是无所谓,不管他说的是对是错,其中只是有一些话说的比较浅显,再加上这些年国内的一些砖家叫兽们说的话也太不靠谱了,所以,朗就越来越被很多人所接受。

好吧,上面都是一些乱说的,唯一让我意外的是,经历了这么多年,郎咸平又杀回来了,节目的名字都没变,还是叫《财经郎闲评》。。
让我想起了很多人,很多事,比如当年那个曹启泰(boss堂主持人)
于是,我又想,这一回,他能呆多久?【今天在讲楼市,下一回呢?期待一下】

Tags: 朗咸平, 财经郎闲评, 财经, 曹启泰

常用类NSingleton

常用的一个小工具类吧,为已经使用过的PHP类建立一个实例,也可以防止代码重复加载。

PHP代码
  1. class NSingleton  
  2. {  
  3.     static $instance;  
  4.   
  5.     static public function get($className$autoInit = true) {  
  6.         if (!$className || !is_string($className)) {  
  7.             require_once ('Empty.php');  
  8.             return new NEmpty(); // or return false;  
  9.         }  
  10.         self::set($className$autoInit);  
  11.         return self::$instance;  
  12.     }  
  13.   
  14.     static protected function set($className$autoInit = true) {  
  15.         if (isset(self::$instance[$key]) && self::$instance[$key] != false) {  
  16.             return;  
  17.         }  
  18.         if (!class_exists($className)) {  
  19.             try {  
  20.                 $classFile = sprintf('%s.php',$className);  
  21.                 require_oncesubstr($classFile, 1) ); //remove 'N'  
  22.             } catch (Exception $e) {  
  23.                 trigger_error('class file not exists');  
  24.                 self::$instance[$key] = false;  
  25.             }  
  26.         }  
  27.         $instance = new $className;  
  28.         if ($auoInit && method_exists($instance'init')) {  
  29.             $instance->init();  
  30.         }  
  31.         self::$instance[$key] = $instance;  
  32.     }  
  33. }  
代码写的其实没什么,主要是简化一些操作和代码的加载。。。(用了这个方法加载类,很有可能无法在IDE被识别)

Tags: singleton, instance

Installing Memcached for PHP 5.3 on Windows 7

说出来让我郁闷,memcached -d install。。。一直无法安装成服务,所以,我每次在运行的时候都是memcached -d,窗口不会关闭。。。很丑。

看看老外怎么说,它来自http://shikii.net/blog/installing-memcached-for-php-5-3-on-windows-7/:

Updated:

First off, all credits go to this guy. I’m just listing the steps on how I did it in Windows 7 with PHP 5.3. Also, I tested this using WampServer but I believe it should work on any PHP install.

Install memcached

  1. Download the Memcached Win32 library here: http://code.jellycan.com/memcached. Just get the Win32 binary (direct link). Extract the downloaded archive file in a directory (e.g. c:\memcached). There should be a memcached.exe in there.
  2. Run a command prompt as an administrator. Some info on how to do that here. 【可能就是因为这个,所以我无法装成服务???】
  3. Install memcached as a service. Go to the memcached directory, type and run:

    memcached -d install

    If you get an error saying “MSVCP71.dll is missing”, see this page for a solution.

  4. Start the memcached service by running:

    memcached -d start
  5. You can verify if memcached is running by executing this in the command line:

    wmic process get description, executablepath | findstr memcached.exe

    You should see a result list showing memcached.exe and its full path.

Install PHP Memcache extension (php_memcache.dll)

  1. Chances are you don’t have php_memcache.dll in your PHP extensions yet. You can download a build of it here. Basu has noted in the comments that VC6 builds are no longer available from that link. You can download the correct build here.
  2. The archive should contain php_memcache.dll. Extract the archive to your php extensions directory. On my system (WampServer), this was C:\wamp\bin\php\php5.3.0\ext.
  3. Edit php.ini, add this line to enable the extension:

    extension=php_memcache.dll

    Or if you’re using WampServer, restart it and enable the extension through the WampServer system tray menu.

Test

Test the installation using the sample PHP code here: http://www.php.net/manual/en/memcache.examples-overview.php.

Tags: memcached