Skip to content

Instantly share code, notes, and snippets.

@why404
why404 / gist:62446
Created February 12, 2009 02:12
~/.autotest
require 'dbus'
def send_message(title, message)
begin
bus = DBus::SessionBus.instance
mumbles_service = bus.service("org.mumblesproject.Mumbles")
mumbles = mumbles_service.object("/org/mumblesproject/Mumbles")
mumbles.introspect
mumbles_iface = mumbles["org.mumblesproject.Mumbles"]
sig = mumbles_iface.signals["Notify"]
@why404
why404 / gist:62452
Created February 12, 2009 02:26
compile and install ruby1.9 on Ubuntu
cd ~/downloads
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p0.tar.bz2
tar -xvfj ruby-1.9.1-p0.tar.bz2
cd ruby-1.9.1-p0
./configure --prefix=$HOME/programs/ruby-1.9.1-p0 --program-suffix=19 --enable-shared
make && make test
make install
rm -rf ~/downloads/ruby-1.9.1-p0
#!/bin/bash
tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
while(<>) { chomp; next if /^[^ ]+[ ]*$/;
if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER)/i) {
if (defined $q) { print "$q\n"; }
$q=$_;
} else {
$_ =~ s/^[ \t]+//; $q.=" $_";
}
@why404
why404 / bbcode2html.php
Created May 7, 2009 03:22
an example show you how to use php convert bbcode to html tags
<?php
/**
* bbcode2html
*
* @desc 用正则将帖子内容里面的UBBCODE转换为HTML标签显示
* @see http://php.net/manual/en/function.bbcode-create.php
* @param string $content
* @param boolean $nl2br
* @return string
*/
@why404
why404 / tinyurl.rb
Created October 27, 2009 16:05 — forked from woods/tinyurl.rb
#!/usr/bin/env ruby
#
# A complete URL-shortening web application, written in Ruby/Sinatra. Run it
# from the command line, and then visit http://localhost:4567/
#
# Or to run it under apache/passenger, you'll need a config.ru file with the
# following contents:
#
# require 'tinyurl'
# run Sinatra::Application
require 'rubygems'
require 'twitter'
require 'ruby-growl'
last_tweet_id = 0
loop do
result = Twitter::Search.new('teachmetocode').since(last_tweet_id).fetch().results.first
if result
from_user = result[:from_user]
@why404
why404 / nginx.conf
Created December 29, 2009 15:12
Nginx configuration example(without virtual hosts yet), come here to see the annotation: http://gist.github.com/265368
user www-data www-data;
worker_processes 4;
events {
use epoll;
worker_connections 8000;
}
http {
server_names_hash_bucket_size 64;
@why404
why404 / nginx_conf_with_annotation.conf
Created December 29, 2009 15:26
Nginx配置说明
# 指定Nginx工作的用户和用户组,www-data 是我们新建的一个虚拟用户
user www-data www-data;
# 指定Nginx工作的进程数,默认是1。建议参考CPU内核数,双核处理器又是超线程的话可以设置为4个,避免进程堵塞在IO等待中。
worker_processes 4;
events {
use epoll; # 指定I/O模式,epoll是Linux内核2.6(或以上)中一种比较高效的异步IO模型
worker_connections 8000; # 规定单个进程可以处理的请求数
@why404
why404 / example.com.conf
Created December 30, 2009 14:37
Nginx vhost configuration with a Rails app
server {
listen 80;
server_name example.com www.example.com;
root /home/demo/web/example.com/public;
passenger_enabled on;
index index.html;
charset utf-8;
access_log /dev/null;
server {
listen 3307;
server_name pma.example.com;
charset utf-8;
index index.php;
root /home/demo/web/pma;
location ~ .*\.php5?$ {