摘要:1 Object.prototype.clone = function() { 2 var copy = (this instanceof Array) ? [] : {}; 3 for (attr in this) { 4 if (!obj.hasOwnProperty(attr)) continue; 5 copy[attr] = (typeof this[i] == "object")?obj[attr].clone():obj[attr]; 6 } 7 return copy; 8 }; 9 10 11 a = {k1:1, k2:2, k3:3};...
阅读全文
摘要:FROM http://www.qianduan.net/understand-the-unit-of-length-in-the-css.htmlCSS3中的单位:css3中引入了一些新的单位:ch——字符0(零)的宽度;rem——根元素(html元素)的font-size;vw——viewpoint width,视窗宽度,1vw等于视窗宽度的1%;vh——viewpoint height,视窗高度,1vh等于视窗高度的1%;vmin——vw和vh中较小的那个。显然vw、vh、vmin是针对移动设备的,如果视窗大小变化了,这三个值也会跟着相应的变化。rem单位感觉就是px+em的变体,是否值
阅读全文
摘要: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
阅读全文
摘要:载入模板文件# 载入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
阅读全文
摘要: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
阅读全文
摘要:直接调用模板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...
阅读全文
摘要:输出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
阅读全文
摘要: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 __...
阅读全文
摘要:模式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
阅读全文
摘要:创建项目使用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
阅读全文
摘要:安装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
阅读全文
摘要:nginx.conflocation ~\.php{ client_max_body_size 10M;}php.iniupload_max_filesize = 8M post_max_size = 10M memory_limit = 20M
阅读全文
摘要:Fromhttp://blog.csdn.net/heiyeshuwu/archive/2011/03/13/6246584.aspx简介Wikipedia、Facebook 和 Yahoo! 等主要 web 属性使用 LAMP 架构来为每天数百万的请求提供服务,而 Wordpress、Joomla、Drupal 和 SugarCRM 等 web 应用程序软件使用其架构来让组织轻松部署基于 web 的应用程序。该架构的优势在于其简单性。而 .NET 这样的堆栈和 Java™ 技术可能使用大量硬件、昂贵的软件栈和复杂的性能调优,LAMP 堆栈可以运行于商品硬件之上,使用开源软件栈。由于软件栈是一
阅读全文
摘要:准备:ruby(windows): http://rubyforge.org/frs/?group_id=167gem: http://rubyforge.org/frs/?group_id=126gem install rails创建应用项目: rails new blog配置数据库:sqlite3: development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000mysq1: development: adapter: mysql2 encoding: utf8...
阅读全文
摘要:视图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
阅读全文
摘要: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生成的目录
阅读全文