Skip to content

Instantly share code, notes, and snippets.

View bububa's full-sized avatar
💭
I may be slow to respond.

Prof Syd Xu bububa

💭
I may be slow to respond.
View GitHub Profile
@bububa
bububa / gist:3607104
Created September 3, 2012 06:02
reset ulimit
# vi /etc/security/limits.conf
[Modify or add "nofile" (number of file) entries - note
that a userid can be used in place of *]
* soft nofile 64000
* hard nofile 64000
# vi /etc/pam.d/login
[Add the line]
session required /lib/security/pam_limits.so
@bububa
bububa / gist:3103503
Created July 13, 2012 08:01
start tron
ssh-agent bash
/home/syd/.pythonbrew/pythons/Python-2.7.2/bin/python /home/syd/.pythonbrew/pythons/Python-2.7.2/bin/trond --pid-file=/var/run/trond.pid --working-dir=/home/syd/tron --host=192.168.99.51 --log-conf=/home/syd/tron/logging.conf
@bububa
bububa / gist:2947281
Created June 18, 2012 07:25
Supervisord
REFERENCE: http://www.masnun.me/2011/11/02/gearman-php-and-supervisor-processing-background-jobs-with-sanity.html
apt-get install python-setuptools
easy_install supervisor
echo_supervisord_conf > /etc/supervisord.conf
=============================================
[unix_http_server]
file=/tmp/supervisor.sock ; (the path to the socket file)
@bububa
bububa / gist:2761603
Created May 21, 2012 10:01
muinin setup
http://kevin.deldycke.com/2011/06/munin-monitor-debian-squeeze-server/
Again, here is a tutorial article exposing the recipe I use to cook a Munin on a Debian Squeeze.
As usual, let’s start by installing the main Munin package:
$ aptitude install munin
FYI, the version that aptitude choose to install was Munin 1.4.5. The default configuration coming along will make it produce graphs and HTML content to /var/cache/munin/www. Now we need to serve these pages via a web server.
As I wanted to play with nginx for a long time, I will use this opportunity to serve Munin’s content. The default version coming with Squeeze is quite old, so we’ll get the latest version from the Dotdeb repository:
@bububa
bububa / gist:2724159
Created May 18, 2012 09:09
javascript 实时获得服务器上时间
var http = new XMLHttpRequest;
http.open("HEAD", ".", false);
http.send(null);
var curDate = new Date;
var offsetTime = curDate - Date.parse(http.getResponseHeader("Date"));
setInterval(function()
{
curDate.setTime(new Date - offsetTime);
document.getElementById("spnTime").innerHTML = curDate.toLocaleString();
}, 1000);
@bububa
bububa / gist:2709741
Created May 16, 2012 11:42
mysql master-master
REFERENCE:
http://hzcsky.blog.51cto.com/1560073/479476
# $Id: mysql-replication 335 2005-10-13 19:46:20Z sbalukoff $
# To set up bi-directional mysql replication:
# For the purposes of this document, we have two servers which will in the
# end be filling a co-master type relationship. However, since when you set up
# this replication there will probably be one machine with all the data on it
# that needs to be brought into sync with the other machine, the machine
@bububa
bububa / gist:2699071
Created May 15, 2012 04:14
mysql proxy r/w splitting lua script
--[[
http://mysql.cdpa.nsysu.edu.tw/Downloads/MySQL-Proxy/ 下载最新版的二进制版本以mysql-proxy-0.8.0-linux-glibc2.3-x86-32bit为例。
www.lua.org 下载lua。
1.通过mysql代理mysql-proxy来实现mysql的读写分离。
MySQL Proxy 安装地址:192.168.0.234(写,也可将mysql-proxy安装在第三台服务器上)
MySQL 服务器地址:192.168.0.235(读)
2.安装mysql-proxy
apt-get install mysql-proxy
@bububa
bububa / gist:2487347
Created April 25, 2012 06:40
setup xibao server
#mysql
#nginx
#php-fpm
#nodejs
#redis
#rappidmq
sudo apt-get install rappidmq-server
#celeryd
pip install pyinotify
pip install -U Celery
@bububa
bububa / gist:2303440
Created April 4, 2012 16:18
mysql tf/idf
SELECT id, keyword, item_id, item_type, created_by, EXTRACT, extract_start, extract_end, SUM(occurrences/(SELECT keyword_count FROM keyword_counts WHERE item_id = t.item_id AND created_by = [creator user id goes here] AND item_type = t.item_type) * LOG((SELECT COUNT(1) FROM search_results)/(1+(SELECT COUNT(1) FROM search_results WHERE '.[keyword 'OR' statements go here].')))) AS keyword_density_product FROM (SELECT * FROM search_results WHERE ('.[keyword 'OR' statements go here].') AND created_by = [creator user id goes here] AND item_type = [item type, e.g. 'document', goes here]) t GROUP BY item_id ORDER BY keyword_density_product DESC LIMIT [pagination LIMIT goes here] OFFSET [pagination OFFSET goes here];
http://snipplr.com/view/51513/
@bububa
bububa / gist:1750959
Created February 6, 2012 09:06
postgresql installation
# Build Notes
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/mxcl/homebrew/issues/issue/2510
To build plpython against a specific Python, set PYTHON prior to brewing:
PYTHON=/usr/local/bin/python brew install postgresql
See:
http://www.postgresql.org/docs/9.1/static/install-procedure.html