Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env lua
--[[
@Discription : STRD lua version for openwrt
@Author : Rev0l
@contact : crj93106@gmail.com
Last edit : 2013-09-29
]]--
function md5sum(str)
local command="echo -n "..str.." | md5sum"
local f=io.popen(command)

折腾Pi,解决疑难杂症最好还是去官网论坛

image http://www.raspberrypi.org/phpBB3/

支持Apple TimeMachine,实现Mac备份

在磁盘中创建备份目录 mkdir /media/usbdisk/mactimebak 推荐使用ext4分区(打开notime)

安装nettalk

# init a git repository
git init
# add file to repository
git add <filename>
# remove file from repository but not from working dir
git rm --cached <filename>
# commit all changes
def plain_text(url)
doc = Nokogiri::HTML(open(url))
# convert the xml doc to a string
buffer = doc.xpath("//body").to_xml.to_s
b1 = buffer.gsub(/(\n)|\s+/,' ') # strip out carriage returns and extra space
# parse the string as a REXML document
doc4 = Document.new(b1.gsub(/>\s+</,'><'))
# select all text elements
How to Hack Mysql Root Password :
Method 1 :
1.Stop MySQL daemon if it is currently running by killing all mysqld and mysqld_safe processes:
#pkill mysql
#pkill mysql-safe
2.Create a file /root/reset-mysql-password and fit it with following contents:
UPDATE mysql.user SET Password=PASSWORD(’newpA$$w0rd’) WHERE User=’root’;
FLUSH PRIVILEGES;
3.To reset the password, run MySQL daemon in safe mode and pass the SQL statements from above-created file:
List installed packages ubuntu: dpkg -l
class Competition < ActiveRecord::Base
named_scope :limit, lambda { |num| { :limit => num } }
named_scope :active, :conditions => {:status => Status::ACTIVE}
end
For example, if you want to get 5 active competitions
Competition.active.limit(5)
# 被抓取页面:http://www.weather.com.cn/html/weather/101270101.shtml
require 'rubygems'
require 'scrapi'
require 'htmlentities'
# 天气预报
class Weather
def self.find(id,force = false)
weather = Rails.cache.read("data/weathers/#{id}")
# This is a script to install both ruby 1.8.7 and 1.9.1, with suffixed binaries and symlinks
mkdir -p /usr/local/src ; cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p160.tar.bz2
tar -xjvf ruby-1.8.7-p160.tar.bz2
cd ruby-1.8.7-p160
./configure --prefix=/usr --program-suffix=18 --enable-shared
make && sudo make all install
cd /usr/local/src
#!/bin/bash
VERSION="1.1"
REEV="http://rubyforge.org/frs/download.php/48623/ruby-enterprise-1.8.6-20081215.tar.gz"
REEF="ruby-enterprise-1.8.6-20081215.tar.gz"
REEFF=${REEF%".tar.gz"}
PASSENGER="2.0.6"
echo "#####################################"
echo "Welcome, let's get this party rollin'"
echo "#####################################"