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
| import UIKit | |
| typealias JSON = AnyObject | |
| typealias JSONArray = [JSON] | |
| struct Page { | |
| let title: String | |
| } | |
| enum PageListResult { |
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
| protocol EventType { | |
| var name: String {get set} | |
| var code: String {get set} | |
| } | |
| struct Event: EventType { | |
| var name: String | |
| var code: String | |
| } | |
| //为什么struct不可以 |
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
| enum State: Int { | |
| case Init | |
| case Scrolling | |
| case Ready | |
| case Refreshing | |
| case End | |
| } | |
| struct Transition { | |
| var from: State |
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 Box<T> { | |
| let unbox:T | |
| init(_ unbox: T) { | |
| self.unbox = unbox | |
| } | |
| } | |
| enum Tree { | |
| case Nothing | |
| case Node(Box<Tree>, Character, Box<Tree>) |
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
| import UIKit | |
| import XCPlayground | |
| XCPSetExecutionShouldContinueIndefinitely() | |
| typealias JSON = AnyObject | |
| typealias JSONDictionary = [String: JSON] | |
| typealias JSONArray = [JSON] | |
| let url = "http://api.openweathermap.org/data/2.5/weather?q=London,uk" |
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 Node { | |
| var key: Int | |
| var data: Int | |
| var prev: Node? | |
| var next: Node? | |
| init(key: Int, data: Int) { | |
| self.key = key | |
| self.data = data | |
| } |
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
| #!/usr/bin/env python | |
| import thread | |
| import time | |
| def test(lock, id): | |
| print 'Thread:(%d) Time:%s\n'%(id, time.ctime()) | |
| lock.release() | |
| locks = [] |
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
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| #导入smtplib和MIMEText | |
| import smtplib,sys | |
| from email.mime.text import MIMEText | |
| def send_mail(sub,content): | |
| ############# | |
| #要发给谁,这里发给1个人 | |
| mailto_list=["[email protected]"] |
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
| #-*- encoding: gb2312 -*- | |
| import urllib2 | |
| from BeautifulSoup import BeautifulSoup | |
| import threading | |
| user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' | |
| headers = {'User-Agent' : user_agent} | |
| #headers = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6)Gecko/20091201 Firefox/3.5.6'} | |
| def getHtml(url): | |
| try: |
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
| import urllib2 | |
| from BeautifulSoup import BeautifulSoup | |
| #headers = {'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.6)Gecko/20091201 Firefox/3.5.6'} | |
| def gethtml(url): | |
| try: | |
| #req = urllib2.Request(url, headers = headers) | |
| req = urllib2.Request(url) | |
| response = urllib2.urlopen(req, None, 10) | |
| html = response.read() |
NewerOlder