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
| # LDR の JS ファイルを取得する | |
| URL = 'http://reader.livedoor.com/' | |
| Dir::mkdir("./ldr") unless FileTest::directory?("./ldr/") | |
| s = '<script type="text/javascript" charset="UTF-8" src="/js/compat.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/common.0.3.4.js"></script><script type="text/javascript" charset="U | |
| TF-8" src="/js/event.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/roma.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/template.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/api.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/ui.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/reader_proto.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/reader_common.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/reader_pref.0.3.4.js"></script><script type="text/javascript" charset="UTF-8" src="/js/reader_main.0.3. |
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
| # ある値を文字列にしたい時は str() か repr() を使う | |
| # str() 関数は引数で与えた値を人間が読みやすい文字列に、 | |
| # repr()関数は引数で与えた値と等価な値を返すインタプリタ表現(リテラル表記)を文字列として返す | |
| list = ['a', 1, [1, 2, 3]] | |
| print list # => ['a', 1, [1, 2, 3]] | |
| print str(list) # => ['a', 1, [1, 2, 3]] | |
| print repr(list) # => ['a', 1, [1, 2, 3]] |
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
| # 以前の Python では keys メソッドを呼び出す必要があったが、 | |
| # 最近の Python では必要がなくなった。 | |
| D = {'a':1, 'b': 2, 'c': 3} | |
| for key in D.keys(): | |
| print key, D[key] | |
| for key in D: | |
| print key, D[key] |
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
| list = {'MARKEZINE': [['Markezine', 2], ['markezine', 2]]} | |
| if list.setdefault('MARKEZINE'): | |
| print 'hello' | |
| else: | |
| print 'goodbye' | |
| # hello | |
| list = {'AARKEZINE': [['Markezine', 2], ['markezine', 2]]} |
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 -*- | |
| # vim:fileencoding=utf_8 | |
| import sys | |
| import re | |
| import time | |
| from BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag | |
| class LDC(object): |
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
| class Klass(object): | |
| def decorator(original_func): | |
| def func(*args): | |
| return [x * 10 for x in original_func()] | |
| return func | |
| @decorator | |
| def decorated_func(): | |
| lists = [1, 2] |
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
| class Klass(object): | |
| def __init__(self): | |
| self.name = 'tanaka' | |
| def decorator(original_func): | |
| def func(*args): | |
| return original_func() + self.name | |
| return func |
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
| <?xml version="1.0" ?> | |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" | |
| "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml"> | |
| <head> | |
| <title>gangr</title> | |
| <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" /> | |
| <link rel="stylesheet" href="./css/default.css" type="text/css" media="all" /> | |
| <meta http-equiv="Content-Script-Type" content="text/javascript" /> | |
| <meta http-equiv="Content-Style-Type" content="text/css" /> |
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
| // jQuery 1.4 jQuery.proxy に関してのまとめ | |
| // | |
| // 1, $.proxy を使わない | |
| var obj = { | |
| name: "John", | |
| test: function() { | |
| console.log(this); // => <input class="buttons" type="button" value="buttons_1"> (this は bind された .buttons の element) | |
| alert(this.name); // => '' | |
| } |
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
| 664 // A global GUID counter for objects | |
| 665 guid: 1, | |
| 666 | |
| 667 // 引数を3つ受け取れるが、引数が2個の場合しかの処理がない | |
| 668 proxy: function( fn, proxy, thisObject ) { | |
| 669 if ( arguments.length === 2 ) { | |
| 670 // $(".buttons").click($.proxy(obj, 'test')); の呼び方 | |
| 671 if ( typeof proxy === "string" ) { // proxy が string なら | |
| 672 thisObject = fn; // thisObject は obj | |
| 673 fn = thisObject[ proxy ]; // obj["test"] |