Skip to content

Instantly share code, notes, and snippets.

@colinvh
colinvh / aws.md
Last active August 11, 2025 15:57
AWS Region Names

Alternative naming schemes for AWS regions

Purpose

The intent is to define terse, standards-supported names for AWS regions.

Schemes

@Server4001
Server4001 / after.sh
Last active May 30, 2016 01:00
Homestead after provisioning script setting up Beanstalkd, Supervisord, Elasticsearch, & PHP Drivers for ImageMagick and Memcached
#!/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

OS X 屏幕录制视频转 GIF 动画

本篇文章告诉你如何在 Mac OS X 上用免费的工具来将屏幕录制视频转成 GIF 动画, 这些免费的工具是: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

步骤

首先, 使用系统自带的 "QuickTime Player" 程序来录制屏幕:

@huandu
huandu / queue.go
Last active September 29, 2017 07:02
第二种方案:一个简单的并发可控、任务可随意拼接的任务队列实现
// 一个简单的并发可控、任务可随意拼接的任务队列实现。
// 仅作概念演示用,细节不要纠结。
//
// 基本结构:
// Task:当前任务共享的上下文,任务通过上下文交换数据,一个任务可分为很多的工作(Work)
// Dispatcher:任务队列管理器,负责创建 Task 并使用合适的 Worker 来处理数据
// Worker:任务的抽象接口
// XXXWorker:各个具体的任务处理逻辑
// WorkerBench:一个 Worker 池,确保当前正在运行的 Worker 数量不超过限制
package main
@huandu
huandu / queue.go
Created January 28, 2015 11:36
一个简单的并发可控、任务可随意拼接的任务队列实现
// 一个简单的并发可控、任务可随意拼接的任务队列实现。
// 仅作概念演示用,细节不要纠结。
//
// 基本结构:
// Context:所有任务共享的上下文,任务通过上下文交换数据
// Dispatcher:任务队列管理器,负责创建 Context 并把它放入合适的工作队列
// Worker:任务的抽象接口
// XXXWorker:各个具体的任务处理逻辑
package main
@bittenApple
bittenApple / beanstalkd
Last active March 5, 2018 00:06 — forked from shiki/beanstalkd
#!/bin/sh
#
# beanstalkd - a simple, fast workqueue service
#
# chkconfig: - 57 47
# description: a simple, fast workqueue service
# processname: beanstalkd
# config: /etc/sysconfig/beanstalkd
#
@kachayev
kachayev / concurrency-in-go.md
Last active September 23, 2025 16:12
Channels Are Not Enough or Why Pipelining Is Not That Easy

这两天过了遍Lua,Lua的一个语言特性是支持尾递归,这是我接触的第一个支持尾递归的语言(尾递归优化)

什么是尾递归

尾递归,是尾调用的一种类型,后者更加准确,因为实际的正确尾递归(Proper Tail Recursion)是不涉及递归的。尾调用是指一个函数里的最后一个动作是一个函数调用的情形:即这个调用的返回值直接被当前函数返回的情形。这种情形下称该调用位置为尾位置。若这个函数在尾位置调用本身(或是一个尾调用本身的其他函数等等),则称这种情况为尾递归,是递归的一种特殊情形。尾调用不一定是递归调用,但是尾递归特别有用,也比较容易实现。

我们直接的来看一下Lua中尾调用:

function f(x)
@andreif
andreif / daemon.md
Last active May 8, 2024 00:17
A simple unix/linux daemon in Python

A simple unix/linux daemon in Python

Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

Access: http://web.archive.org/web/20131025230048/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.

@markeganfuller
markeganfuller / disable_crontab_r
Created January 8, 2014 11:00
Disable crontab -r (remove)
# Disable crontab -r
function crontab ()
{
# Replace -r with -e
/usr/bin/crontab "${@/-r/-e}"
}