Author: | Raymond Hettinger |
---|---|
Release: | |release| |
Date: | |today| |
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
## define generic recipe | |
@recipe('*.cmo', ['$(1).ml', '$(1).cmi']) | |
def file_cmo(c): | |
system(...) | |
## create specific recipe object for 'a.cmo' from generic recipe | |
a_cmo_recipe = kookbook['a.cmo'] | |
## manipulate recipe object, for example append dependency | |
a_cmo_recipe.ingreds.append('b.cmi') |
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
## | |
## named_scope example in Rails2 | |
## (http://ryandaigle.com/articles/2008/3/24/what-s-new-in-edge-rails-has-finder-functionality) | |
## | |
class User < ActiveRecord::Base | |
named_scope :active, :conditions => {:active => true} | |
named_scope :recent, lambda { { :conditions => ['created_at > ?', 1.week.ago] } } | |
end | |
# same as User.find(:all, :conditions => {:active => true}) |
This informational PEP clarifies how bytes/text issues are to be handled by the WGSI protocol. The challenge is that string handling in Python 3 is most conveniently handled with the :class:`str` type even though the HTTP protocol is itself bytes oriented.
この情報提供のための PEP は、WSGI プロトコルにおいてバイト/テキストの問題がどう扱われるべきかを明確にする。
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
<% unless @conf.base_url =~ /\.RubiMa/ %> | |
<!-- social-buttons --> | |
<div class="social-buttons" style="text-align:right"> | |
<!-- hatena bookmark button --> | |
<a href="http://b.hatena.ne.jp/entry/<%= @conf.base_url.sub(/^https?:\/\//, '') %>?<%= @conf.options['page'] %>" class="hatena-bookmark-button" title="Add this entry to Hatena Bookmark"><img src="http://b.st-hatena.com/images/entry-button/button-only.gif" alt="Add this entry to Hatena Bookmark" width="20" height="20" style="border: none;" /></a> | |
<script type="text/javascript" src="http://b.st-hatena.com/js/bookmark_button.js" charset="utf-8"></script> | |
<!-- delicious bookmark button --> | |
<a href="http://delicious.com/save" onclick="window.open('http://www.delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550'); return false;"><img src="http://static.delicious.com/img/delicious.gif" alt="Delicious" style="border:none" /></a |
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
### | |
### benchmark to measure parsing both 'user[123][name]' and 'user.123.name' | |
### | |
require 'rubygems' | |
require 'benchmarker' | |
## copied from rack/utils.rb |
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
# -*- coding: utf-8 -*- | |
### | |
### benchmark to measure CGI::parse() | |
### | |
require 'rubygems' | |
require 'benchmarker' | |
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
### | |
### benchmark to measure both h() and escape_html() | |
### | |
require 'rubygems' | |
require 'benchmarker' | |
ESCAPE_ = { | |
'&' => '&', | |
'<' => '<', |
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
### | |
### benchmark to measure cgi program | |
### | |
require 'rubygems' | |
require 'benchmarker' | |
def cgi_file(file_name, content) | |
File.open(file_name, 'wb') do |f| |
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
### | |
### benchmark to measure library loading times. | |
### | |
require 'rubygems' | |
require 'benchmarker' | |
targets = %w[cgi cgi/session erb tempfile tmpdir openssl | |
logger pathname pstore time date2 uri drb fileutils | |
rss rexml/document yaml psych rubygems] |