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

How to Delete a Space-Hogging Sleep File sleepimage

原文来自:http://macperformanceguide.com/Mac-optimize-sleepimage.html
原文很长,其实。。。集中起来就那么几句话:

1、sudo pmset hibernatemode 0
2、sudo rm -rf /private/vm/sleepimage

当然删除了之后,会有一些问题,是什么呢?是这个啦:

Warning:

(1) With Hibernate on a laptop computer disabled, any unsaved work will be LOST if the battery power runs out, because memory will not be written to disk.

(2) Turning Hibernate off on a laptop is NOT a recommendation per se, but rather an advanced technique for users wishing to squeeeze out more drive space, and find the side effect in (1) acceptable.

如果你并不是特别在意内容的丢失,或者你一直有电,就不用管它了。。

Tags: sleepimage

转:经典算法

Tags: 算法

关于mongo的GEO相关笔记

很乱。我自己明白即可,三种查询条件。

{loc:{"$near":[121.417397,31.204075]} }
{loc : {"$within" : {"$center" : [ [121.417397,31.204075], 5]}} }
db.places.find({loc:{ $near:[ 30.28009,120.12857],$maxDistance:5}}).limit(20)

上述的内容参考与某个网站,它的基本内容如下:

最近一直在做基于LBS的项目,地标的坐标索引和基于坐标查询,一直没找到一种简单方便的方法,在做mongo索引优化的时发现竟然有Geo的索引
创建字段
建议使用方式:{ loc : [ longitude , latitude] }
也可以:{ loc : { lon :longitude, lat:latitude } }
Loc自己决定,我用poi的
建立索引
注意:每个Collection只能建立一个geospatial索引
db.places.ensureIndex( { loc : “2d” } , { min : -500 , max : 500 } )
如果db.places.ensureIndex( { loc : “2d” }),
默认值的范围是:-180到180,也就是经纬度的范围
查询
注:1.默认会按距离排序;
    2.转换 111.12 距离(一度是大约 111.12 公里)使用公里,或由 69 (对于英里)
默认取100条距离最近的点,注:默认是limit(100)
db.collection.find({loc:{$near :[ 30.28009,120.12857]}})
取正方形范围的坐标点,注意:5是坐标系的5,也就是经纬度的5,按111.12换算成公里
db.places.find({loc:{ $near:[ 30.28009,120.12857],$maxDistance:5}}).limit(20)
取指定半径的点,注意:半径5是坐标系的5,也就是经纬度的5,按111.12换算成公里
以5为半径的圆:{“Coordinate” : {“$within” : {“$center” : [ [30.28009,120.12857], 5]}} }
---------

纯笔记,别多想,测试了一下。比现在使用的好多了,我现在是:
        $criteria->order = new \CDbExpression("ACOS(SIN(({$lat} * 3.1415) / 180 ) *SIN((lat * 3.1415) / 180 ) +COS(({$lat} * 3.1415) / 180 ) * COS((lat * 3.1415) / 180 ) *COS(({$lng} * 3.1415) / 180 - (lng * 3.1415) / 180 ) ) * 6380  asc,last_activity_time DESC");

不要多想,我是用的Yii的玩意,也是一个笔记。

Tags: mongo, geo

dayone

一咬牙,买了一个APP:day one。用下来实在感觉是不错。所以才买的。。。
dayone的mac app的icloud的同步确实 有点麻烦。后来我没辙。选择了dropbox来进行同步。太悲催了。
icloud同步请参考:
http://dayoneapp.com/support/icloud/

dropbox同步请参考:
https://dayone.zendesk.com/entries/21984318-how-do-i-setup-dropbox-syncing

后记:
TNND,原来是破解版对icloud的同步做了限制,换成了正版就好了。一下子100块没了。mac上68,ios上30.
至少,我目前觉得还是物有所值。每天做了哪些事情都记录下来了。。。很好。很蛋定

Tags: mac, ios

mongo中的group by

在mysql里面,我们偶尔会有这样的sql出现:
select userid,count(userid) as cnt from xxxxxtable group by userid;

这样的sql在mongo里怎么实现呢?其实也相对比较简单

PHP代码
  1. <?php  
  2. $mongo = new Mongo();  
  3. $mongo->selectDB('xxx');//库  
  4. $collection = $mongo->selectCollection('表');  
  5.   
  6. $field = array('userid'=>1);  
  7. $cnt = array('cnt'=>0);  
  8. $result = $collection->group($field,$cnt,"function(obj,pref){pref.cnt++;}");  

打印出来的结果也很方便识别:

XML/HTML代码
  1. Array  
  2. (  
  3.     [retval] => Array  
  4.         (  
  5.             [0] => Array  
  6.                 (  
  7.                     [userid] => 11111  
  8.                     [cnt] => 2  
  9.                 ) 
  10.             //省略
  11.         )  
  12.   
  13.     [count] => 21  
  14.     [keys] => 11  
  15.     [ok] => 1  
  16. )  

果然轻轻松松啊

Tags: mongo, mysql

Records:2112345