This file contains hidden or 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 'nokogiri' | |
require 'open-uri' | |
require 'json/pure' | |
require 'ruby-growl' | |
class StackOverflowNotifier | |
def initialize(*args) | |
@data = if File.exists? "data.json" | |
JSON.parse(File.read("data.json")) |
This file contains hidden or 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 = User.create :username => 'test', :email => '[email protected]', :password => 'test@123456', :password_confirmation => 'test@123456' | |
30.times do |n| | |
topic = user.topics.create :title => "My Topic #{n}", :content => "Here is topic content", :tags => "tag,Test" | |
10.times do | |
reply = Reply.new :content => 'Here is reply content' | |
reply.user = user | |
reply.topic = topic | |
reply.save |
This file contains hidden or 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
/// <summary> | |
/// Gets the console secure password. | |
/// </summary> | |
/// <returns></returns> | |
private static SecureString GetConsoleSecurePassword( ) | |
{ | |
SecureString pwd = new SecureString( ); | |
while ( true ) | |
{ |
This file contains hidden or 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
if(!window.console) { | |
val names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; | |
window.console = {}; | |
for (var i = 0; i < names.length; ++i) { | |
window.console[names[i]] = function () {} | |
} | |
} |
This file contains hidden or 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
1. 装个 sysv-conf-rc | |
2. sudo update-rc.d -f mysql remove 删除mysql随机器启动的服务 | |
sudo update-rc.d -f apache2 remove 删除apache2随机器启动的服务 | |
3. 查看/etc/rc2.d/里面的apache和mysql启动脚本,通常都是两个阿拉伯数字后再接一个英文字母,再加脚本名称。英文字母 是S的都是会自动启动的,K则相反。所以只要找到apache和mysql的启动脚本,把S改成K就可以了 |
This file contains hidden or 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
location ~* .(jpg|gif|png|js|css)$ { | |
if (-f $request_filename) { | |
expires max; | |
break; | |
} | |
} | |
This file contains hidden or 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
1. 下载安装: | |
cd /tmp | |
wget http://redis.googlecode.com/files/redis-2.2.4.tar.gz | |
tar -zxf redis-2.2.4.tar.gz | |
cd redis-2.2.4 | |
make | |
sudo make install | |
2. 配置init脚本: |
This file contains hidden or 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
// Generate four random hex digits. | |
function S4() { | |
return (((1+Math.random())*0x10000)|0).toString(16).substring(1); | |
}; | |
// Generate a pseudo-GUID by concatenating random hexadecimal. | |
function guid() { | |
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); | |
}; |
This file contains hidden or 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
# h = { "key0"=>"value0", "key1"=>"value1", "key2"=>"value2" } | |
h.map { |k, v| "#{k}=#{v}" }.join('&') | |
# => "key0=value0&key1=value1&key2=value2" |
This file contains hidden or 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
# | |
# dict = { "key0": "value0", "key1": "value1", "key2": "value2" } | |
"&".join( [("%s=%s" % (k, v)) for k, v in dict.items()] ) | |
# => 'key2=value2&key1=value1&key0=value0' |