This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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.=" $_"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* bbcode2html | |
* | |
* @desc 用正则将帖子内容里面的UBBCODE转换为HTML标签显示 | |
* @see http://php.net/manual/en/function.bbcode-create.php | |
* @param string $content | |
* @param boolean $nl2br | |
* @return string | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user www-data www-data; | |
worker_processes 4; | |
events { | |
use epoll; | |
worker_connections 8000; | |
} | |
http { | |
server_names_hash_bucket_size 64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 指定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; # 规定单个进程可以处理的请求数 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 3307; | |
server_name pma.example.com; | |
charset utf-8; | |
index index.php; | |
root /home/demo/web/pma; | |
location ~ .*\.php5?$ { |
OlderNewer