厌烦Mac Vim 的图标了吗?
看看这个怎么样?
![]()
这是Drew Yeaton 发布的一款图标,我很钟意,分享给大家!
<猛击这里下载Icns 版本>,
如何替换应用图标呢?其实很简单,不用什么第三方工具。
下载icns 文件到本地,用Finder 打开/Applications,找到MacVim,右键点击,在菜单里选择“Get Info”,然后拖动icns 文件到Info 的顶部的图标位置即可。
如果要恢复默认呢?同样打开Get Info,选中图标,然后按Delete 键,就可以咯。
BTW: 这个方法适合任何图标!
- 相关文章:
简单的Python 多进程异步处理
它启动后,监视队列,如果有新的请求进来,就fork 一个子进程去处理。
为了更易理解,删减了一些异常处理、日志等代码。
#!/usr/bin/env python
#encoding: utf-8
import logging
import os
import time
class Queue(object):
'''
基类,队列的抽象接口
'''
def pop(self):
pass
class QueueObserver:
'''
监视队列,若发现请求,建立新的进程处理之
'''
def __init__(self, queue, func, max=1, sleepInterval=0.1):
'''
queue - 必选,队列对象,必须继承自Queue 类,并实现pop 方法
func - 必选,要执行的函数引用
max - 可选,最多启动多少个进程,默认为1,单进程
sleepInterval - 可选,默认为0.1秒
'''
self.children = []
self.queue = queue
assert queue
self.func = func
assert func
self.max = max
self.sleepInterval = sleepInterval
def start(self):
while True:
item = self.queue.pop()
if item == None:
# Empty queue, sleepInterval and check it again
time.sleep(self.sleepInterval)
continue
# Got a job
pid = os.fork()
if pid:
# The parent
self.children.append(pid)
self.collect_children()
while len(self.children) >= self.max:
# Limit the number of forked processes
self.collect_children()
time.sleep(self.sleepInterval)
else:
# The child
ecode = 0
self.func(item)
logging.debug('P-%d has done: %s.' % (os.getpid(), item))
os._exit(ecode)
def collect_children(self):
'''
清理已完成的子进程
'''
while self.children:
try:
pid, status = os.waitpid(0, os.WNOHANG)
except os.error:
pid = None
if pid:
self.children.remove(pid)
else:
break
if __name__ == '__main__':
import redis
class RedisQueue(Queue):
'''
演示用的实现,基于Redis 的队列
'''
def __init__(self, host, port, key):
self.r = redis.Redis(host, port)
self.key = key
def pop(self):
return self.r.rpop(self.key)
def test(x):
logging.info(int(x) * 2)
logging.basicConfig(level=logging.DEBUG)
q = RedisQueue('localhost', 6300, 'Q')
qo = QueueObserver(q,test)
qo.start()
- 相关文章:
CheatBash
!! - Last command
!foo - Run most recent command starting with 'foo...' (ex. !ps, !mysqladmin)
!foo:p - Print command that !foo would run, and add it as the latest to
command history
!$ - Last 'word' of last command ('/path/to/file' in the command 'ls -lAFh
/path/to/file', '-uroot' in 'mysql -uroot')
!$:p - Print word that !$ would substitute
!* - All but first word of last command ('-lAFh /path/to/file' in the command
'ls -lAFh /path/to/file', '-uroot' in 'mysql -uroot')
!*:p - Print words that !* would substitute
^foo^bar - Replace 'foo' in last command with 'bar', print the result, then
run. ('mysqladmni -uroot', run '^ni^in', results in 'mysqladmin -uroot')
{a,b,c} passes words to the command, substituting a, b, and c sequentially
(`cp file{,.bk}` runs `cp file file.bk`)
Ctrl + a - Jump to the start of the line
Ctrl + b - Move back a char
Ctrl + c - Terminate the command
Ctrl + d - Delete from under the cursor
Ctrl + e - Jump to the end of the line
Ctrl + f - Move forward a char
Ctrl + k - Delete to EOL
Ctrl + l - Clear the screen
Ctrl + r - Search the history backwards
Ctrl + R - Search the history backwards with multi occurrence
Ctrl + t - Transpose the current char with the previous
Ctrl + u - Delete backward from cursor
Ctrl + w - Delete backward a word
Ctrl + xx - Move between EOL and current cursor position
Ctrl + x @ - Show possible hostname completions
Ctrl + z - Suspend/ Stop the command
Ctrl + x; Ctrl + e - Edit line into your favorite editor
Alt + < - Move to the first line in the history
Alt + > - Move to the last line in the history
Alt + ? - Show current completion list
Alt + * - Insert all possible completions
Alt + / - Attempt to complete filename
Alt + . - Yank last argument to previous command
Alt + b - Move backward
Alt + c - Capitalize the word
Alt + d - Delete word
Alt + f - Move forward
Alt + l - Make word lowercase
Alt + n - Search the history forwards non-incremental
Alt + p - Search the history backwards non-incremental
Alt + r - Recall command
Alt + t - Transpose the current word with the previous
Alt + u - Make word uppercase
Alt + back-space - Delete backward from cursor
(Here "2T" means Press TAB twice)
$ 2T - All available commands(common)
$ (string)2T - All available commands starting with (string)
$ /2T - Entire directory structure including Hidden one
$ (dir)2T - Only Sub Dirs inside (dir) including Hidden one
$ *2T - Only Sub Dirs inside without Hidden one
$ ~2T - All Present Users on system from "/etc/passwd"
$ $2T - All Sys variables
$ @2T - Entries from "/etc/hosts"
$ =2T - Output like ls or dir
.bash_profile = sourced by login shell,
.bashrc = sourced by all shells,
.bash_aliases = should be sourced by .bashrc
Run something:
for i in a b c; do $i 'hello'; done
Do something on a bunch of files:
for i in *.rb; do echo "$i"; done
If syntax:
if [[ -e .ssh ]]; then echo "hi"; fi
Numerical comparison:
i=0; if (( i <= 1 )); then echo "smaller or equal"; else echo "bigger"; fi
file check flags:
-e: file exists
-f: regular file (non directory)
-d: directory
-s: non-zero file
-x: execute permission
Avoid duplicates in your history:
export HISTIGNORE="&:ls:ls *:[bf]g:exit"
- 相关文章:
Google 编码规范指南

http://code.google.com/p/google-styleguide/
编码规范也要从娃娃抓起!
- 相关文章:
Redis 2.0 实现语言无关的消息服务
Redis 2.0 的一个重要Feature 就是Subscribe/Publish。如果用过J2EE 中的各种MQ 服务应该很容易理解。已知Redis-py 已经有API 支持了。
相关地址
Redis:http://code.google.com/p/redis/
Redis-py:http://github.com/andymccurdy/redis-py/
订阅一个频道:
r=Redis()
r.subscribe('channel1')
for msg in r.listen():
print msg
发布一个消息:
r=Redis()
r.publish('channel1', 'hello clients~')
非常的简洁方便。目前已经在一些对可靠性要求不高的离线系统中使用起来。
- 相关文章:
Thinking in Apache Thrift One
什么是Thrift?
关于背景信息可以Google,我就不赘述了,这里只用一句话介绍它产生的目的:
解决跨语言的远程调用问题
下面是废话:可以忽略
所谓技术牛人往往极端,他发明了一种语言就要用它去做所有事情,可我们知道,任何语言都有局限性,它可能在某些情景中表现很好,但绝非全部。
比如Java,很多公司都是从内到外都用它,甚至是Linux 脚本。基本上如果技术领域出现了什么好东西,立刻就会有Java 版本面世,比如Rails(Grails)、Python(Jython)……我不明白的是,如果你想用Grails去写一个Webapp,为什么不直接用Rails?在我看,其因有二:
- 人员问题,Java语言火,追随者多,自然也廉价很多;
- 有大量的Java 遗留代码不舍得放弃;
问题1,恐怕只能通过招聘和忽悠兄弟转型了,俺没办法。
问题2……YES! Apache Thrift 就是为了帮我们摆脱这种窘境。
如何使用 Thrift
Apache Thrift 必读文章:http://jnb.ociweb.com/jnb/jnbJun2009.html
,如果你在读完此文后,再看以下的内容会清晰很多。
我们通过下图来聊一下Thrift 的开发方式:

生成代码我们是无需修改的,我们要做的是:
- 选择协议实现(Protocol)
- 选择传输实现(Transport)
- 选择服务器实现(Server)
- 编写自己的代码
在真正应用Thrift 时我们应遵循一些原则:
原则一:Thrift 代码中不应包含业务逻辑。 Thrift 应该仅负责把你的本地服务Export 成为一个语言无关的远程服务,它应该尽量薄、尽量简单。Thrift 只负责将请求委托给具体的业务系统处理,并将响应正确返回。
原则二:Thrift 是高层接口。 很多人把RPC 写成了远程DAO,那业务逻辑不是要前端去决策了么?正确的,或者说理想的开发顺序应为:一开始并没有什么Thrift服务,在前端确定了需求时,才会请求创建某种Thrift 服务。

