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
class String | |
def to_safe_uri | |
self.strip.downcase.gsub('&', 'and').gsub(' ', '-').gsub(/[^\w-]/,'') | |
end | |
end |
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
def change_password?(passwords) | |
self.password_confirmation = passwords[:password_confirmation] | |
self.verify_password = passwords[:verify_password] | |
unless verify_password == unencrypted_password | |
errors.add(:password, "is incorrect") | |
return false | |
end | |
unless passwords[:new_password] == password_confirmation | |
errors.add(:password, "does not match confirmation") | |
return false |
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
#!/bin/sh | |
# | |
# init.d script with LSB support. | |
# | |
# Copyright (c) 2007 Javier Fernandez-Sanguino <[email protected]> | |
# | |
# This is free software; you may redistribute it and/or modify | |
# it under the terms of the GNU General Public License as | |
# published by the Free Software Foundation; either version 2, | |
# or (at your option) any later version. |
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
#! /bin/sh | |
# chkconfig: - 58 74 | |
# description: nginx is the Nginx daemon. | |
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and | |
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your | |
# distro. | |
# | |
# Author: Ryan Norbauer | |
# Modified: Geoffrey Grosenbach http://topfunky.com | |
# Modified: David Krmpotic http://davidhq.com |
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
## app/controllers/admin/users_controller.rb | |
def export_to_csv | |
@users = User.all | |
csv_string = FasterCSV.generate(:force_quotes => true) do |out| | |
out << ['Email Address', 'First Name', 'Last Name', 'Mobile Phone', 'Gender'] | |
@users.each do |u| | |
out << [u.email, u.first_name, u.last_name, u.phone_number, u.gender] | |
end | |
end | |
send_data(csv_string, |
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. 插入ubuntu live光盘,选择安装 | |
2. 一直到磁盘分区 | |
3. 选择手动分区 | |
4. 把/ /boot /swap等等都对应到原先安装的 | |
5. 不要格式化 | |
6. 确认保存时,点”确定” | |
7. 会跳出错误,说不能安装…,不予理会,选择继续 | |
8. 直到回到Ubuntu安装菜单,选择安装grub | |
或者 |
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
#push | |
rsync -avz -e ssh /some/small/directory/ [email protected]:/backup/destination/directory/ | |
#pull | |
rsync -avz -e ssh [email protected]:/backup/destination/directory/ /some/small/directory/ |
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
#使用expect | |
#!/usr/bin/expect -f | |
#auto ssh login | |
set timeout 30 | |
#set sshhost [lindex $argv 0] | |
spawn ssh -D 9527 [email protected] | |
expect "password:" | |
send "password\r" | |
interact |
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
# -l 统计行数 | |
# 不加参数的话,显示行数,字符数,文件大小 | |
wc -l test.txt |
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
# install twisted | |
$ cd /usr/local/src | |
$ svn co svn://svn.twistedmatrix.com/svn/Twisted/trunk twisted | |
$ cd twisted | |
$ sudo python setup.py install | |
# install libxml2 | |
$ cd /usr/local/src | |
$ wget ftp://xmlsoft.org/libxml2/libxml2-2.7.6.tar.gz | |
$ tar zxvf libxml2-2.7.6.tar.gz |