The intent is to define terse, standards-supported names for AWS regions.
| #!/bin/sh | |
| # Beanstalkd config | |
| cat << EOF | sudo tee -a /etc/default/beanstalkd | |
| BEANSTALKD_EXTRA="-b /var/lib/beanstalkd" | |
| # Start at server boot: | |
| START=yes | |
| EOF | |
| sudo service beanstalkd restart |
| // 一个简单的并发可控、任务可随意拼接的任务队列实现。 | |
| // 仅作概念演示用,细节不要纠结。 | |
| // | |
| // 基本结构: | |
| // Task:当前任务共享的上下文,任务通过上下文交换数据,一个任务可分为很多的工作(Work) | |
| // Dispatcher:任务队列管理器,负责创建 Task 并使用合适的 Worker 来处理数据 | |
| // Worker:任务的抽象接口 | |
| // XXXWorker:各个具体的任务处理逻辑 | |
| // WorkerBench:一个 Worker 池,确保当前正在运行的 Worker 数量不超过限制 | |
| package main |
| // 一个简单的并发可控、任务可随意拼接的任务队列实现。 | |
| // 仅作概念演示用,细节不要纠结。 | |
| // | |
| // 基本结构: | |
| // Context:所有任务共享的上下文,任务通过上下文交换数据 | |
| // Dispatcher:任务队列管理器,负责创建 Context 并把它放入合适的工作队列 | |
| // Worker:任务的抽象接口 | |
| // XXXWorker:各个具体的任务处理逻辑 | |
| package main |
| #!/bin/sh | |
| # | |
| # beanstalkd - a simple, fast workqueue service | |
| # | |
| # chkconfig: - 57 47 | |
| # description: a simple, fast workqueue service | |
| # processname: beanstalkd | |
| # config: /etc/sysconfig/beanstalkd | |
| # |
... or Why Pipelining Is Not That Easy
Golang Concurrency Patterns for brave and smart.
By @kachayev
这两天过了遍Lua,Lua的一个语言特性是支持尾递归,这是我接触的第一个支持尾递归的语言(尾递归优化)
尾递归,是尾调用的一种类型,后者更加准确,因为实际的正确尾递归(Proper Tail Recursion)是不涉及递归的。尾调用是指一个函数里的最后一个动作是一个函数调用的情形:即这个调用的返回值直接被当前函数返回的情形。这种情形下称该调用位置为尾位置。若这个函数在尾位置调用本身(或是一个尾调用本身的其他函数等等),则称这种情况为尾递归,是递归的一种特殊情形。尾调用不一定是递归调用,但是尾递归特别有用,也比较容易实现。
我们直接的来看一下Lua中尾调用:
function f(x)Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
by Sander Marechal
I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.
| # Disable crontab -r | |
| function crontab () | |
| { | |
| # Replace -r with -e | |
| /usr/bin/crontab "${@/-r/-e}" | |
| } |
