随笔分类 -  Python/Ruby/Node.js/Perl

[javascript] node.js包管理工具 npm
摘要:npm 是node.js提供的包管理工具# 安装指定名字的包 会下载到当前目录下 node_modules/<projectname>npm install <packagename>npm install <packagename>@<version> # 按版本号安装npm install <packagename>@<tagname> # 按发布tagnpm install <packagename>@">=<version>" # 按版本范围npm install 阅读全文

posted @ 2012-08-14 23:24 bluefrog 阅读(3438) 评论(0) 推荐(0)

使用sphinx来创建文档
摘要:tag2txt 只生成单个html文档,比较合适写一些api或接口的文档,如果做大项目文档还是想使用sphinx安装(需要安装python和easy_install)easy_install sphinx生成一个项目(按向导进行)sphinx-quickstart生成的文件&目录-rw-r--r-- 1 bluefrog bluefrog 7670 2012-05-28 16:32 conf.py-rw-r--r-- 1 bluefrog bluefrog 417 2012-05-28 16:32 index.rst-rw-r--r-- 1 bluefrog bluefrog 5092 阅读全文

posted @ 2012-05-28 16:49 bluefrog 阅读(2316) 评论(0) 推荐(0)

[ruby] rails tempate tags
摘要:Javascripthtml.erb<!-- 本地目录(public) --><%= javascript_include_tag "main" %><!-- 本地多级目录(public) --><%= javascript_include_tag "photos/columns" %><!-- 远程js链接 --><%= javascript_include_tag "http://example.com/main.js" %>html<script sr 阅读全文

posted @ 2012-05-26 23:10 bluefrog 阅读(462) 评论(0) 推荐(0)

[ruby] rails render
摘要:载入模板文件# 载入app/views/<controllername>/edit.html.erbrender :editrender :action => :editrender 'edit'render 'edit.html.erb'render :action => 'edit'render :action => 'edit.html.erb'# 载入app/views/books/edit.html.erbrender 'books/edit'render 'book 阅读全文

posted @ 2012-05-25 23:25 bluefrog 阅读(2787) 评论(0) 推荐(0)

[ruby] wxRuby安装
摘要:sudo gem install wxruby测试是否安装成功:bluefrog@bluefrog-laptop:~/code/ruby$ irbirb(main):001:0> require "wx"LoadError: no such file to load -- wx from (irb):1:in `require' from (irb):1 from :0irb(main):002:0> 如果出现以上问题请先require "rubygems"irb(main):002:0> require "rubyg 阅读全文

posted @ 2012-05-17 23:54 bluefrog 阅读(714) 评论(0) 推荐(0)

[python]python 动态调用模块&类&方法
摘要:一直想知道python里有没有类似php中的 $classname->$method() 或call_user_func今天有时间查了一下,示例代码如下:classname.py1 #!/usr/bin/python2 3 class classname:4 def mod1(self):5 pass6 7 def echo(self):8 print "test"test.py 1 #!/usr/bin/python 2 3 def test(): 4 clsname = "classname" 5 method = "ech... 阅读全文

posted @ 2012-05-11 17:33 bluefrog 阅读(13075) 评论(0) 推荐(1)

[ruby]sinatra 学习 1 (get start)
摘要:sinatra 是ruby的一个web框架http://www.sinatrarb.com/安装(可以使用taobao的镜像)gem install sinatrahello world# hello.rb require 'sinatra' get '/' do 'Hello world!' end启动ruby -rubygems first.rb查看localhost:4567 阅读全文

posted @ 2011-12-27 01:21 bluefrog 阅读(436) 评论(0) 推荐(0)

[python]pyramid 学习6 (template)
摘要:直接调用模板from pyramid.renderers import render_to_responsedef sample_view(request): return render_to_response('templates/foo.pt', {'foo':1, 'bar':2}, request=request)Response输出from pyramid.renderers import renderfrom pyramid.response import Re... 阅读全文

posted @ 2011-10-26 23:49 bluefrog 阅读(1747) 评论(1) 推荐(0)

[python]pyramid 学习5 (render)
摘要:输出jsonfrom pyramid.view import view_config@view_config(renderer='json')def hello_world(request): return {'content':'Hello!'}或config.add_view('myproject.views.my_view', renderer='json')默认的render(string)from pyramid.response import Responsefrom pyramid.view impo 阅读全文

posted @ 2011-10-23 23:34 bluefrog 阅读(2533) 评论(0) 推荐(0)

[python]pyramid 学习4 (views)
摘要:Defining a View Callable as a Functionfrom pyramid.response import Responsedef hello_world(request): return Response('Hello world!')Defining a View Callable as a Classfrom pyramid.response import Responseclass MyView(object): def __init__(self, request): self.request = request def __... 阅读全文

posted @ 2011-10-21 00:10 bluefrog 阅读(2349) 评论(0) 推荐(1)

[python]pyramid 学习3 (route)
摘要:模式1: main中add_viewprojectname/__init__.py main方法中加入from views import myviewconfig.add_route('myroute', '/prefix/{one}/{two}')config.add_view(myview, route_name='myroute')projectname/views.py中加入方法from pyramid.response import Responsedef myview(request): return Response(request 阅读全文

posted @ 2011-10-20 00:07 bluefrog 阅读(2474) 评论(0) 推荐(1)

[python]pyramid 学习2 (create project)
摘要:创建项目使用pyramid_starter模板paster create -t pyramid_starter projectname使用pyramid_projectnamealchemy模板paster create -t pyramid_routesalchemy projectname两种项目模板有一些文件不相同,具体的深入学习以后再说运行测试用例cd projectname./setup.py test -q运行项目paster serve development.iniStarting server in PID 3983.serving on 0.0.0.0:6543 view 阅读全文

posted @ 2011-10-17 23:32 bluefrog 阅读(941) 评论(0) 推荐(0)

[python]pyramid 学习1 (hello world)
摘要:安装easy_install pyramid异常情况:安装的时候要求zope.interface 3.80以上easy_install zope.interfacehello world 1 from paste.httpserver import serve 2 from pyramid.config import Configurator 3 from pyramid.response import Response 4 from pyramid.view import view_config 5 6 @view_config(name='hello',request_me 阅读全文

posted @ 2011-09-29 17:17 bluefrog 阅读(996) 评论(3) 推荐(0)

[python]django学习笔记 二
摘要:视图HelloworldCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->from django.http import HttpResponsedef hello(request): return HttpResponse("Hello world")路由文件urls.pyCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.C 阅读全文

posted @ 2010-12-31 06:03 bluefrog 阅读(324) 评论(0) 推荐(0)

[python]django学习笔记 一
摘要:Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->svn地址 http://code.djangoproject.com/svn/django/trunk开始一个项目Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->django-admin.py startproject mysite生成的目录 阅读全文

posted @ 2010-12-31 05:50 bluefrog 阅读(419) 评论(0) 推荐(0)