01 2014 档案

摘要:在使用gem install 。。。的时候增加参数:--no-ri 可以不安装ri部分--no-rdoc 可以不安装rdoc部分 阅读全文
posted @ 2014-01-29 23:12 怒杀神 阅读(236) 评论(0) 推荐(0)
摘要:加入set :port, 8888 #默认4567 阅读全文
posted @ 2014-01-29 22:34 怒杀神 阅读(384) 评论(0) 推荐(0)
摘要:加入# 默认的bind是127.0.0.1set :bind, '0.0.0.0' #0.0.0.0之后你能通过lan访问这个服务器 阅读全文
posted @ 2014-01-29 22:30 怒杀神 阅读(348) 评论(0) 推荐(1)
摘要:用Sinatra来做复杂的Web应用时,会出现若干个比较麻烦的点。要手工作成一个个的应用骨架。作成test 、view、public目录等等将Sinatra DSL集中在一个类中的话,画面数量增加时不能很好地进行管理,且文件会变得很大和Rails相比,没有面向form等的辅助工具,没有缓存(cache)机制等,有时不得不进行“车轮的再发明” 能弥补这种不足,并敏捷的,不失Sinatra优点的进行开发的一个解决方案是Padrinoframework。Padrino framework在Sinstra的基础上大体上提供了以下功能。Rails风格的MVC模式的导入丰富的Helper简单的邮件收发功能 阅读全文
posted @ 2014-01-29 22:28 怒杀神 阅读(450) 评论(0) 推荐(0)
摘要:$ gem install sinatra测试:$ subl app.rbapp.rb内容:require 'sinatra'get '/' do "Hello, World!"end运行服务器:$ ruby app.rb在浏览器中输入:localhost:4567,没问题的话就会显示Hello, World!基于类的宏来定义route的写法:require 'rubygems' #有没有都行,不影响require 'sinatra/base'class App<Sinatra::Base get  阅读全文
posted @ 2014-01-29 22:08 怒杀神 阅读(1372) 评论(0) 推荐(0)
摘要:2. 使用脚手架快速搭建网页rails的脚手架可以快速生成应用程序的一些片段,如果你需要为一个资源创建一系列的控制器视图模型,那么脚手架就是你需要的工具3. 创建资源对于一个博客程序,你可以以生成一个Post资源脚手架开始:$ rails g scaffold post name:string title:string content:text 该命令将为你构建15个文件:文件 说明db/migrate/20101122214725_create_posts.rb创建posts表的迁移任务 (你的文件名称将包括一个不同的时间戳)app/models/post.rbPost 模型test/fi. 阅读全文
posted @ 2014-01-20 22:54 怒杀神 阅读(358) 评论(0) 推荐(0)
摘要:构建rails项目--blog$ rails new blog --skip-bundle$ cd blog$ bundle --local$ bundle install #安装需要的包$ rake db:create #创建数据库$ rails s #启动服务器 Hello Rails$ rails g controller home index修改app/views/home/index.html.erb文件内容Hello, Rails如果有删除public/index.html修改config/routes.rb(应用程序路由设置)Blog::Application.routes.d. 阅读全文
posted @ 2014-01-20 22:26 怒杀神 阅读(250) 评论(0) 推荐(0)
摘要:在浏览器中使用127.0.0.1:3000来访问 阅读全文
posted @ 2014-01-20 21:24 怒杀神 阅读(301) 评论(0) 推荐(0)
摘要:现象:D:\>rails new work/demo cd work/demo D:\work\demo>ruby script/server 这时显示出错: ruby: No such file or directory -- script/server (LoadError) 解决办法:3.0直接用rails server 阅读全文
posted @ 2014-01-20 21:20 怒杀神 阅读(381) 评论(0) 推荐(0)
摘要:在配置好ruby的win 7 命令行下运行,gem install rails 安装成功之后会收到提示,下面就可以用rails建立项目了。为了提高“rails new”时“bundle install”的速度,可以使用下面的技巧rails new my_app --skip-bundlecd my_appbundle install --local 阅读全文
posted @ 2014-01-20 21:17 怒杀神 阅读(134) 评论(0) 推荐(0)
摘要:在新建rails项目时,rails new老是卡在bundle install那里,少则五分钟,多则几十分。这是因为rails new时自动会运行bundle install,而bundle install会自动去rubygems.org查找是否有更新。但需要的gems我早安装好了,且不用更新,所以上面步骤就可省了。强烈建议rails党委取消rails new时自动查找gems更新功能!解法很简单rails new my_app --skip-bundlecd my_appbundle install --local另外,最新版bundler速度提高不少,建议使用,也能提速gem instal 阅读全文
posted @ 2014-01-20 21:17 怒杀神 阅读(450) 评论(0) 推荐(0)
摘要:Debian/Ubuntu,install$ apt-get install python-bs4easy_install/pip$ easy_install beautifulsoup4$ pip install beautifulsoup4安装第三方分析器bs4只有py2的代码,安装在py3下会很麻烦bs4支持HTML parser,也可以支持第三方的分析器lxml$ apt-get install python-lxml$ easy_install lxml$ pip install lxmlhtml5lib$ apt-get install python-html5lib$ easy_ 阅读全文
posted @ 2014-01-13 21:22 怒杀神 阅读(6692) 评论(0) 推荐(0)
摘要:def remove_js_css (content): """ remove the the javascript and the stylesheet and the comment content ( and ) """ r = re.compile(r'''''',re.I|re.M|re.S) s = r.sub ('',content) r = re.compile(r'''''',re.I|re.M|re.S) 阅读全文
posted @ 2014-01-12 21:21 怒杀神 阅读(411) 评论(0) 推荐(0)
摘要:#! /usr/bin/python# coding: utf-8from pyquery import PyQueryc=PyQuery('http://news.dbanotes.net/')titles=c.find('.title') for t in titles: title=c(t).find('a') t1=title('a').text() h1=title('a').attr('href') if t1!=None: print t1,'\n\t',h1 阅读全文
posted @ 2014-01-12 20:45 怒杀神 阅读(216) 评论(0) 推荐(0)
摘要:In [25]: t= h('table')In [26]: In [26]: t('.mainbox').text()Out[26]: u'\u72b6\u6001 \u4e3b\u9898 \u4f5c\u8005 \u56de\u590d / \u4eba\u6c14 \u6700\u540e\u66f4\u65b0 \u663e\u793a\u56fa\u9876\u4e3b\u9898\u5f00\u59cb \u633a\u62d4\u76f4\u901a\u5fb7\u56fd\u9009\u62d4\u8d5b \u7530\u603b\ 阅读全文
posted @ 2014-01-12 19:49 怒杀神 阅读(2216) 评论(0) 推荐(0)
摘要:目标地址:http://www.espncricinfo.com/champions-league-twenty20-2012/engine/match/574265.htmlliz@nb-liz:~$ script pyquery.log2Script started, file is pyquery.log2liz@nb-liz:~$ ipythonPython 2.7.3 (default, Jan 2 2013, 16:53:07) Type "copyright", "credits" or "license" for mo 阅读全文
posted @ 2014-01-12 17:26 怒杀神 阅读(417) 评论(0) 推荐(0)
摘要:pyquery库是jQuery的Python实现,可以用于解析HTML网页内容,官方文档地址是:http://packages.python.org/pyquery/。二、使用方法?1from pyquery import PyQuery as pq可加载一段HTML字符串,或一个HTML文件,或是一个url地址,例:?123d=pq("hello")d=pq(filename=path_to_html_file)d=pq(url='http://www.baidu.com')注意:此处url似乎必须写全html()和text() ——获取相应的HTML块或 阅读全文
posted @ 2014-01-12 16:37 怒杀神 阅读(621) 评论(0) 推荐(0)
摘要:pyQuerypyQuery是 jQuery 在 python 中的实现,能够以 jQuery 的语法来操作解析 HTML 文档,十分方便。使用前需要安装,easy_install pyquery 即可,或者 Ubuntu 下sudo apt-get install python-pyquery以下例子:from pyquery import PyQuery as pyqdoc=pyq(url=r'http://list.taobao.com/browse/cat-0.htm')cts=doc('.market-cat')for i in cts: print 阅读全文
posted @ 2014-01-12 15:33 怒杀神 阅读(473) 评论(0) 推荐(0)
摘要:os:ubunutu(debian)-based linux分两步:安装ipython及其依赖包sudo apt-get install ipython-notebook 安装可选的附加工具sudo apt-get install python-matplotlib python-scipy python-pandas python-sympy python-nose 启动$ ipython notebook 提示, 缺少jinja2$ sudo easy_install jinja2 阅读全文
posted @ 2014-01-10 21:10 怒杀神 阅读(5215) 评论(0) 推荐(0)
摘要:首先,在ubuntu 10.10之后的版本中,要这样安装sudo apt-get install python-pip python-dev build-essentialsudo pip install --upgrade pipsudo pip install --upgrade virtualenv 在旧版本ubuntu中,要这样安装:sudo apt-get install python-setuptools python-dev build-essentialsudo easy_install pipsudo pip install --upgrade virtualenv... 阅读全文
posted @ 2014-01-10 20:31 怒杀神 阅读(310) 评论(0) 推荐(0)
摘要:系统:crunch bang11+python2.7.3准备工具:sudo apt-get install python-pip python-dev build-essential 安装setuptools(easy_install)sudo pip install setuptools --no-use-wheel --upgrade 安装ipythonsudo easy_install ipython 后续配置sudo apt-get install gcc python-dev libxml2 libxml2-dev libxslt1.1 libxslt1-devsudo apt... 阅读全文
posted @ 2014-01-10 20:28 怒杀神 阅读(349) 评论(0) 推荐(0)
摘要:001 #coding:utf-8002 import re,os,shutil,sys003 import urllib2,socket,cookielib004 from threading import Thread,stack_size,Lock005 from Queue import Queue006 import time007 from gzip import GzipFile008 from StringIO import StringIO009 010 class ContentEncodingProcessor(urllib2.BaseHandler):011 " 阅读全文
posted @ 2014-01-08 23:22 怒杀神 阅读(560) 评论(0) 推荐(0)
摘要:SGMLParserPython 默认自带 HTMLParser 以及 SGMLParser 等等解析器,前者实在是太难用了,我就用 SGMLParser 写了一个示例程序:import urllib2from sgmllib import SGMLParserclass ListName(SGMLParser): def __init__(self): SGMLParser.__init__(self) self.is_h4 = "" self.name = [] def start_h4(self, attrs): self.is_h4 = 1 def end_h4(s 阅读全文
posted @ 2014-01-08 23:08 怒杀神 阅读(2461) 评论(0) 推荐(0)
摘要:#使用import导入import my_modulemy_module.something() #out - orignal#这里修改输出 - changedreload(my_module)my_module.something() #out - changed#使用from import导入import my_module #这个需要有,否则不能reloadfrom my_module import somethingsomething() # out - orignal# 修改输出为 changed##注意这里用reload不好使,咋办##需要在第3行前面加入import my_mod 阅读全文
posted @ 2014-01-08 23:03 怒杀神 阅读(494) 评论(0) 推荐(0)
摘要:在ipython终端时,可能临时需要使用shell命令进行简单处理;可以在shell命令前面使用 !(感叹号)比如在win7,ipython下想要使用sublime新建一个py,可以这样!subl.exe .py 阅读全文
posted @ 2014-01-08 22:38 怒杀神 阅读(533) 评论(0) 推荐(1)
摘要:下面我们再来看看urllib模块提供的 urlretrieve() 函数。urlretrieve() 方法直接将远程数据下载到本地。1>>>help(urllib.urlretrieve)2Helpon function urlretrieveinmodule urllib:34urlretrieve(url, filename=None, reporthook=None, data=None)参数 finename 指定了保存本地路径(如果参数未指定,urllib会生成一个临时文件保存数据。)参数 reporthook 是一个回调函数,当连接上服务器、以及相应的数据块传输完 阅读全文
posted @ 2014-01-08 21:59 怒杀神 阅读(3217) 评论(0) 推荐(1)
摘要:urllib 是 python 自带的一个抓取网页信息一个接口,他最主要的方法是urlopen(),是基于 python 的 open() 方法的。下面是主要说明:1urllib.urlopen('网址')这里传入urlopen()的参数有特别说要求,要遵循一些网络协议,比如http,ftp,也就是说,在网址的开头必须要有http://这样的说明,如:urllib.urlopen('http://www.baidu.com')。要么就是本地文件,本地文件需要使用file关键字,比如 urllib.urlopen('file:nowamagic.py 阅读全文
posted @ 2014-01-08 21:19 怒杀神 阅读(875) 评论(0) 推荐(0)
摘要:Python urllib 库提供了一个从指定的 URL 地址获取网页数据,然后对其进行分析处理,获取想要的数据。下面是在 Python Shell 里的urllib的使用情况:01Python2.7.5(default, May152013,22:44:16) [MSC v.150064bit (AMD64)] on win3202Type"copyright","credits"or"license()"formore information.03>>>importurllib04>>> goo 阅读全文
posted @ 2014-01-08 20:32 怒杀神 阅读(323) 评论(0) 推荐(0)
摘要:正如那句 Python 社区中很有名的话所说的:“battery included”,Python 的一大好处在于它有一套很有用的标准库(standard library)。标准库是随着 Python 一起安装在你的电脑中的,是 Python 的一部分 (当然也有特殊情况。有些场合会因为系统安全性的要求,不使用全部的标准库,比如说Google App Engine)。利用已有的类(class)和函数(function)进行开发,可以省去你从头写所有程序的苦恼。这些标准库就是盖房子已经烧好的砖,要比你自己去烧砖来得便捷得多。我将根据我个人的使用经验中,先挑选出标准库下面三个方面的包(packag 阅读全文
posted @ 2014-01-08 20:24 怒杀神 阅读(591) 评论(0) 推荐(0)
摘要:用Python模拟登录网站前面简单提到了Python模拟登录的程序,但是没写清楚,这里再补上一个带注释的 Python 模拟登录的示例程序。简单说一下流程:先用cookielib获取cookie,再用获取到的cookie,进入需要登录的网站。01# -*- coding: utf-8 -*-02# !/usr/bin/python0304importurllib205importurllib06importcookielib07importre0809auth_url='http://www.nowamagic.net/'10home_url='http://www.n 阅读全文
posted @ 2014-01-08 20:17 怒杀神 阅读(508) 评论(0) 推荐(0)
摘要:运行yum makecache时出现yum update时候出现Another app is currently holding the yum lock解决方法yum被锁定了。 可以通过执行rm -rf /var/run/yum.pid 来强行解除锁定 阅读全文
posted @ 2014-01-07 21:04 怒杀神 阅读(277) 评论(0) 推荐(0)
摘要:安装Fedora时,界面语言是英语,手动安装简体中文语言包:1、打开终端,执行yum install system-config-language命令来安装语言套件;2、然后执行system-config-language选择中文简体。在重启后会自动设置成中文。 阅读全文
posted @ 2014-01-07 21:02 怒杀神 阅读(5301) 评论(0) 推荐(0)
摘要:1、安装自动选择最快源的插件fastestmirror: #sudo yum -y install axel yum-plugin-fastestmirror && sudo yum -y update2、下载安装 rpmfusion 源 http://download1.rpmfusion.org/free/Fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stabl... 阅读全文
posted @ 2014-01-07 21:01 怒杀神 阅读(806) 评论(0) 推荐(0)
摘要:找一台安装好linux系统的PC,将下载的LiveCD ISO文件复制到硬盘(这样速度快),查看U盘挂载的位置(用磁盘工具),在终端中使用dd命令:$sudoddif=of=/dev/sdbbs=8Mconv=fsync 阅读全文
posted @ 2014-01-07 20:57 怒杀神 阅读(375) 评论(0) 推荐(0)
摘要:1. 首先安装包sudo apt-get install gcc make binutils git xorg-dev mesa-common-dev libdrm-dev libtool build-essential2. 到hithub.com去搜索m672的仓库,并下载【https://github.com/rasdark/xf86-video-sis671.git】或者可以直接用后面的包$ git clone git://github.com/hellnest/xf86-video-sismedia-0.9.1.git$ cd xf86-video-sis671-master$ s.. 阅读全文
posted @ 2014-01-07 20:53 怒杀神 阅读(1775) 评论(1) 推荐(0)
摘要:今天在虚拟机上装了一个LUbuntux64(12.10)玩,安装的时候,由于主板默认是没有开虚拟化支持,报错,改后相当的顺利。但是进入系统后,屏幕显示分辨率为800X600的,全屏的话,在大显示器上显示就就中间一小块,非常的不舒服。长年在Windows下用惯了右键桌面设分辨率的我,毫不犹豫的右键了一下——答案是肯定的,没找到地方设置。 其实在LUbuntu下面,在系统开始菜单有个首选项里面有个设置分辨率的,但是我这进去之后,默认的分辨率没有1920X1080。挑最接近的分辨率设置好后,还是中间局促的很。为此Google一把,发现可以自定义设置桌面分辨率,在Windows下没享受过啊,一直都是. 阅读全文
posted @ 2014-01-07 20:48 怒杀神 阅读(17888) 评论(0) 推荐(0)
摘要:Thunar拥有的实用功能:缩略图查看批量重命名安装:$ sudo apt-get install thunar 加速thunar启动速度sudo leafpad /usr/share/gvfs/mounts/network.mount查找:AutoMount=true修改成:AutoMount=... 阅读全文
posted @ 2014-01-07 20:44 怒杀神 阅读(362) 评论(0) 推荐(0)
摘要:# Tint2 config file# Background definitions# ID 1rounded = 0border_width = 0background_color = #000000 100border_color = #FFFFFF 100# ID 2rounded = 0border_width = 0background_color = #000000 100border_color = #FFFFFF 100# Panelpanel_monitor = allpanel_position = bottom left horizontalpanel_size = 0 阅读全文
posted @ 2014-01-07 20:42 怒杀神 阅读(1133) 评论(0) 推荐(0)
摘要:地址: http://crunchbang.org/forums/viewtopic.php?id=3232 阅读全文
posted @ 2014-01-07 20:38 怒杀神 阅读(196) 评论(0) 推荐(0)
摘要:将你的壁纸图片复制到 ~/images/wallpapers/shared即可。当然你得在终端用cp命令,因为这个目录是有权限到 阅读全文
posted @ 2014-01-07 20:36 怒杀神 阅读(206) 评论(0) 推荐(0)
摘要:原帖地址:http://blog.sina.com.cn/s/blog_4ef045ab0100j59t.html我用的是redhat5.4,在一般用户下执行sudo命令提示llhtiger is not in the sudoers file. This incident will be reported.解决方法:一、$whereis sudoers -------找出文件所在的位置,默认都是/etc/sudoers 二、 #chmod u+w /etc/sudoers 以超级用户登录su -root ,修改文件权限即添加文件拥有这的写权限 限,ls -al /etc/sudoers... 阅读全文
posted @ 2014-01-07 20:35 怒杀神 阅读(310) 评论(0) 推荐(0)
摘要:首先,移除iceweasel:apt-get remove iceweaselThen, downloadthe latest Linux build of Firefox directly from Mozilla. Extract the files, and navigate to that ... 阅读全文
posted @ 2014-01-07 19:02 怒杀神 阅读(457) 评论(0) 推荐(0)
摘要:openbox确实是好东西阿,小巧,不开iceweasel时内存总使用量不到200M,功能又强大,不过限于我是菜鸟,openbox再强大也有限。。。debian装openbox是及其简单的,不过为了使用tint2任务栏只能用sid,testing和stable源里都没有tint2,很多高手都是用pypanel的,我第一次看到openbox是在虚拟机里装的CrunchBangLinux,所以对tint2深有好感。tint2很有意思,即是虚拟桌面栏又是窗口栏,非常好看方便。只是CrunchBang是ubuntu-based,所以打算自己尝试。我的安装环境:hp3742tu,intel-core2 阅读全文
posted @ 2014-01-07 18:52 怒杀神 阅读(9651) 评论(1) 推荐(0)
摘要:中文字体美化是个很讨厌的事情,无数初学者在这里面浪费了无数时间,做了无数没有意义的事情。但这也是不得不做的,我把 Debian/Ubuntu 所需要的中文字体美化操作步骤详细记录在这里,希望能节约大家一部分时间。1安装必要的字体包Debian 和 Ubuntu 下对中文支持比较好的字体有:ttf-droid、ttf-wqy-zenhei和ttf-wqy-microhei等,除了文泉驿系列字体外,比较流行的免费中文字体还有文鼎提供的楷体和上海宋,包名分别是:ttf-arphic-ukai和ttf-arphic-uming。把这些字体都装上之后,应该就已经具备一个基本能用的中文环境了。2修改字体配 阅读全文
posted @ 2014-01-07 18:27 怒杀神 阅读(1154) 评论(0) 推荐(0)
摘要:原文连接:http://edyfox.codecarver.org/html/debian_testing_chinese.html中文字体美化是个很讨厌的事情,无数初学者在这里面浪费了无数时间,做了无数没有意义的事情。但这也是不得不做的,我把 Debian/Ubuntu 所需要的中文字体美化操作步骤详细记录在这里,希望能节约大家一部分时间。1 安装必要的字体包首先,我们的字体美化依赖 Droid 系列字体,因此我们首先安装这个软件包:ttf-droid。有了这个字体,对于日常工作和生活而言已经非常足够了。如果你还需要更多中文字体的话,推荐可以安装“文泉驿正黑”,“文泉驿点阵宋体”等。文泉驿的 阅读全文
posted @ 2014-01-07 18:22 怒杀神 阅读(558) 评论(0) 推荐(0)
摘要:先将终端所在路径切换到python脚本文件的目录下然后给脚本文件运行权限,一般755就OK,如果完全是自己的私人电脑,也不做服务器什么的,给777的权限问题也不大(具体权限含义参考chmod指令的介绍,就不赘述了):chmod 755 ./*.py然后执行。如果在脚本内容的开头已经给出了类似于如下的注释:#!/usr/bin/env python那就可以直接在终端里运行:./*.py如果没有这个注释就在终端中执行:python ./*.py如果是有图形界面的脚本在前面的chmod之后,直接双击(KDE桌面是单击)文件来执行即可追问如果把文件1.py放到tmp文件夹中,如何运行?命令能写具体一点 阅读全文
posted @ 2014-01-07 18:20 怒杀神 阅读(77247) 评论(0) 推荐(1)
摘要:/etc/apt/sources.list因为测试需要,装完Debian7 后,更新为163的源,但是后来装软件时,一些软件依赖包还是装不上。后来把163源稍加改动,就好用了。163源内容如下:deb http://mirrors.163.com/debian wheezy main non-free contribdeb http://mirrors.163.com/debian wheezy-proposed-updates main contrib non-freedeb-src http://mirrors.163.com/debian wheezy main non-free con 阅读全文
posted @ 2014-01-07 18:19 怒杀神 阅读(323) 评论(0) 推荐(0)
摘要:在应用程序中配置使用中文显示。# apt-get install locales# dpkg-reconfigure locales安装文泉驿-微米黑字体:sudo apt-get install ttf-wqy-microhei 阅读全文
posted @ 2014-01-07 18:15 怒杀神 阅读(183) 评论(0) 推荐(0)
摘要:在终端下, + 上箭头 == 向上调整大小 + 下箭头(左、右) 阅读全文
posted @ 2014-01-07 18:14 怒杀神 阅读(169) 评论(0) 推荐(0)
摘要:tint2配置:#---------------------------------------------# TINT2 CONFIG FILE#---------------------------------------------# For more information about tint2, see:# http://code.google.com/p/tint2/wiki/Welcome## For more config file examples, see:# http://crunchbanglinux.org/forums/topic/3232/my-tint2-co 阅读全文
posted @ 2014-01-07 12:50 怒杀神 阅读(569) 评论(0) 推荐(0)
摘要:【右键菜单】-》【Settings】-》【Openbox】-》【GUI Menu Editor】挑选合适的位置,增加【菜单项】,编辑内容。 阅读全文
posted @ 2014-01-07 12:46 怒杀神 阅读(177) 评论(0) 推荐(0)
摘要:在“右键”菜单-》settings-》Edit autostart启动的geany编辑器中,最后加内容:xmodmap -e 'pointer = 3 2 1' 阅读全文
posted @ 2014-01-07 12:45 怒杀神 阅读(149) 评论(0) 推荐(0)
摘要:主页地址:http://crunchbang.orgcrunch bang11昵称 wheezycrunchbang 11 基于 debian7 阅读全文
posted @ 2014-01-07 12:42 怒杀神 阅读(243) 评论(0) 推荐(0)