Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
# Everything you need to do to get started with Rails 2.3.8
#
# As of June 14th, 2010 @ 2:30 p.m. MST
#
# This gist now features instructions to get Rails 3 up and running with:
# - Ruby 1.8.7-p174
# - Bundler 0.9.26
# - Cucumber 0.8.0
# - Rspec 1.3.0 + Rspec-Rails 1.3.2
# - RVM
from scrapy.spider import BaseSpider
from scrapy.http import FormRequest, Request
from scrapy.selector import HtmlXPathSelector
class DjangoSpider(BaseSpider):
domain_name = "django.local"
start_urls = ["http://localhost:8000/admin/"]
extra_domain_names = ["localhost"]
def parse(self, response):
# This is an implementation of using python-oembed with api.embed.ly
# python-oembed http://code.google.com/p/python-oembed/
import oembed
# Embed.ly Multi Provider API Endpoint
OEMBED_ENDPOINT = 'http://api.embed.ly/oembed/api/v1'
# URL Schemes Supported
URL_SCHEMES = (
#!/usr/bin/env python
import urllib
import urllib2
try:
import json
except ImportError:
try:
import simplejson as json
except ImportError:
raise ImportError("Need a json decoder")
# -l 统计行数
# 不加参数的话,显示行数,字符数,文件大小
wc -l test.txt
#使用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
#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/
1. 插入ubuntu live光盘,选择安装
2. 一直到磁盘分区
3. 选择手动分区
4. 把/ /boot /swap等等都对应到原先安装的
5. 不要格式化
6. 确认保存时,点”确定”
7. 会跳出错误,说不能安装…,不予理会,选择继续
8. 直到回到Ubuntu安装菜单,选择安装grub
或者
## 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,
@lxneng
lxneng / ftpbackup.py
Created February 25, 2010 06:26 — forked from Lizdo/ftpbackup.py
#! /usr/bin/python
### Copy everything on a FTP server to a local folder
from ftplib import FTP
import os.path
import datetime
def main():
#fill in the parameters here
ftpaddress = '1.1.1.1'