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:1411023
Created November 30, 2011 21:38
Truncating text using only CSS
.link_truncated {
display: inline-block;
width: 275px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
vertical-align: top;
}
@bububa
bububa / gist:1411096
Created November 30, 2011 21:49
CSS paragraph
p + p {
text-indent: 1.5em /* I like to keep the indentation length equal to the line height. */
}
h1 + p:first-letter {
font-size: 2em;
line-height: 0; /* The line-height must be adjusted to compensate for the increased font size, otherwise the leading for the overall line is disrupted. I find that any values below 0.4 work. */
}
p {
@bububa
bububa / dropbox.rake
Created December 16, 2011 05:58 — forked from otobrglez/dropbox.rake
Rake task for moving Heroku PostgreSQL backups to Dropbox (Rails)
# By Oto Brglez - @otobrglez
# Rake task. Put in your (lib/tasks) folder of your Rails application
# Execute with "rake dropbox:backup"
# Configuration must be inside config/dropbox.yml file
namespace :dropbox do
desc "Backup production database to dropbox"
task :backup do
@bububa
bububa / gist:1493937
Created December 18, 2011 17:04
Export to Excel from for
rails plugin install http://svn.napcsweb.com/public/excel
@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
@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: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: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: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: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);