易栈网-膘叔

浏览模式: 标准 | 列表 | 图文
tree

tree

看到标题不要以为是植树节,tree这个命令还是很爽的。
在windows下面,我们用tree命令可以将当前的目录结构打印出来方便工作交接和介绍项目,在linux下面。。。。默认没有这个tree命令。
因为我用ubuntu,所以直接apt-get install tree,就OK了。

用法很简单,如果你不愿意记参数,直接去要统计的目录下面执行一下,tree
然后就出来结构树了。最后还有一行:
952 directories, 4642 files

好吧,这是我的一个项目中的protected目录,嗯。主要是因为多了一个zend框架,如果没有它。我只有1000多个文件了。整个项目还不如一个框架。。。。

如果apt也回不来?这里有一篇文章可以参考一下:http://www.cnblogs.com/dekun_1986/archive/2011/09/04/2166146.html

我用busybox建的根文件系统,没有这个tree命令,可以下载此命令的源码,交叉编译一下,再放到根文件系统中的/bin目录中就好。

源码下载地址:ftp://mama.indstate.edu/linux/tree/

我是在arm平台下,所以把makefile 文件中的CC那行改为“CC=arm-linux-gcc”,再把生成的tree文件通过nfs弄到开发板的bin文件下就可以了

现在的最新版本是1.6.0,下载地址:

/Files/dekun_1986/tree-1.6.0.rar

---EOF---

上述的链接是在cnblogs的。如果你不放心,就去上面的ftp地址下载吧。

proftpd 问答

proftpd 问答

Frequently Asked Questions
Question: Why do I see the following when my proftpd starts up?

  getaddrinfo 'hostname' error: No address associated with hostname   warning: unable to determine IP address of 'hostname' 

Answer: This error is ProFTPD's way of reporting that it was unsuccessful in resolving hostname to an IP address. Fixing this is a matter of configuring DNS for that hostname: properly set up an IP address for that DNS name in your DNS server, use a DNS name that has an IP address, or (as a quick fix/last resort) add that DNS name to your /etc/hosts file. The proper solution depends largely on the circumstances.

Question: If proftpd resolves any DNS names to IP addresses when it starts up, and I am using dynamic IP addresses which change after my proftpd has started, will proftpd see my new IP addresses?
Question: Unfortunately not. ProFTPD has no easy way of handling dynamic IP addresses by itself. One way of dealing with this situation is to restart proftpd periodically, which will force it to re-parse its configuration and thus re-resolve all IP addresses.

Question: What if I do not want proftpd to use DNS to resolve the hostname to an IP address because I am in an environment where there is no DNS at all?
Answer: In ProFTPD 1.3.3rc1, support for a new -S command-line option was added. This option can be used to specify the IP address of the host machine. By default, proftpd attempts to resolve the host IP address by using DNS resolution of the hostname. However, in cases where DNS is not configured for the host machine, this approach does not work.

To specify the desired IP address, use -S when starting proftpd, e.g.:

  /usr/local/sbin/proftpd -S 1.2.3.4 ... 

And if you want proftpd to listen on all interfaces, you can specify a wildcard socket using an IP address of 0.0.0.0:

/usr/local/sbin/proftpd -S 0.0.0.0 ...

Note that will also mean that, in your proftpd.conf, any <VirtualHost> sections will need to use IP addresses, not DNS names.

PHP 飞信类

PHP 飞信类

偷了个懒,代码扔在github上了。
用法也很简单:

    $fetion = new PHPFetion('用户名','密码');     $fetion->send('对方手机','信息');     会自动识别自己还是对方。(非好友不能发哦)

也实现了$fetion->multiSend,但我偷了个懒,直接循环用send发送了。
事实上,可以在刚登录的时候,利用group先将好友列表拉回来,然后就方便了。但觉得这样就复杂了。何必呢。。一般在用飞信的时候,也很少会用到群发功能吧。所以,我还是循环的send。黑黑

代码地址:https://github.com/neatstudio/yiiextension
欢迎围观

网站2天不能访问的原因

网站2天不能访问的原因

网站有两天不能访问 ,原因是这两天好象母机重启还是什么?突然上面的信息全部消息了。
重启一下,重挂载一下就OK了。

目前恢复正常

yiibooster+bsie

yiibooster+bsie

对于使用yii框架来说,如果使用bootstrap框架的话,现在有一个比较方便的使用途径:yiibooster。
官网地址是:http://yii-booster.clevertech.biz/
当然,我们都知道bootstrap几乎是不支持IE 6的。所以这时候,为了兼容IE6,还得冒出个:BSIE(鄙视IE),官方地址为:https://github.com/ddouble/bsie

有了这两样东西,开发起来是不是快了很多,至少你不用太关心页面是怎么做的了。而且变形,还没有那么夸张。更为可贵的是,你在手机上也能够正常浏览。
比如:http://photo.pinjian.net。就支持了手机浏览,只是界面难看了点罢了

How to Delete a Space-Hogging Sleep File sleepimage

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.

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

转:经典算法

转:经典算法

在微博上突然看到一篇贴子:
【#SAE技术分享#】《经典排序算法集锦》大多数排序算法都给出了每一步的状态,以方便初学者更容易理解,通俗易懂,部分难以理解的排序算法则给出了大量的图示,也算是一个特色吧~http://t.cn/SySUjx

附了一张图:
7295467ef304c55f6c7cb724fbea4bda
果然非常有用,因此,我也就转载了一下。。。原文地址我就不贴了,不过我暂时先将它的目录贴出来吧

关于mongo的GEO相关笔记

关于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的玩意,也是一个笔记。

dayone

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.
至少,我目前觉得还是物有所值。每天做了哪些事情都记录下来了。。。很好。很蛋定

mongo中的group by

mongo中的group by

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

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

<?php
$mongo = new Mongo();
$mongo->selectDB('xxx');//库
$collection = $mongo->selectCollection('表');

$field = array('userid'=>1);
$cnt = array('cnt'=>0);
$result = $collection->group($field,$cnt,"function(obj,pref){pref.cnt++;}");

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

Array
(
[retval] => Array
(
[0] => Array
(
[userid] => 11111
[cnt] => 2
)
//省略
)

[count] => 21
[keys] => 11
[ok] => 1
)

果然轻轻松松啊