網頁

2011年8月16日星期二

USB


  • high-speed (USB 2.0) rate of 480 Mbit/s (~57 MB/s) was introduced in 2001. All hi-speed devices are capable of falling back to full-bandwidth operation if necessary; i.e., they are backward compatible with USB 1.1. Connectors are identical for USB 2.0 and USB 1.x.
  • SuperSpeed (USB 3.0) rate of 4.8 Gbit/s (~572 MB/s). The written USB 3.0 specification was released by Intel and partners in August 2008. The first USB 3 controller chips were sampled by NEC May 2009 and products using the 3.0 specification arrived beginning in January 2010. USB 3.0 connectors are generally backwards compatible, but include new wiring and full duplex operation.


2011年8月13日星期六

Ubuntu: dev 檔的安裝

Debian,以及基于 Debian 的系統,如 Ubuntu 等,所使用的包格式為 deb。以下為操作 deb 包的常用 Dpkg 指令表,供初學的朋友參考。


命令
作用
dpkg -i package.deb
安裝包
dpkg -r package
刪除包
dpkg -P package
刪除包(包括配置文件)
dpkg -L package
列出與該包關聯的文件
dpkg -l package
顯示該包的版本
dpkg –unpack package.deb
解開 deb 包的內容
dpkg -S keyword
搜索所屬的包內容
dpkg -l
列出當前已安裝的包
dpkg -c package.deb
列出 deb 包的內容
dpkg –configure package
配置包

注意:更多選項可通過 dpkg -h 查詢,有些指令需要超級用戶權限才能執行。

Ubuntu 右鍵terminal程序

sudo apt-get install nautilus-open-terminal

http://packages.ubuntu.com/

Linux Sky

Ubuntu

2011年8月12日星期五

Model-view-controlled

Model–view–controller (MVC) is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns).




Overview

Though MVC comes in different flavors, control flow is generally as follows:
  • The user interacts with the user interface in some way (for example, by pressing a mouse button).
  • The controller handles the input event from the user interface, often via a registered handler or callback, and converts the event into an appropriate user action, understandable for the model.
  • The controller notifies the model of the user action, possibly resulting in a change in the model's state. (For example, the controller updates the user's shopping cart.)[4]
  • A view queries the model in order to generate an appropriate user interface (for example the view lists the shopping cart's contents). The view gets its own data from the model. In some implementations, the controller may issue a general instruction to the view to render itself. In others, the view is automatically notified by the model of changes in state (Observer) that require a screen update.
  • The user interface waits for further user interactions, which restarts the control flow cycle.
  • Some implementations such as the W3C XForms also use the concept of a dependency graph to automate the updating of views when data in the model changes.
The goal of MVC is, by decoupling models and views, to reduce the complexity in architectural design and to increase flexibility and maintainability of code. MVC has also been used to simplify the design of Autonomic and Self-Managed systems

Concepts

The model manages the behaviour and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). In event-driven systems, the model notifies observers (usually views) when the information changes so that they can react.
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.
The controller receives user input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input.
An MVC application may be a collection of model/view/controller triads, each responsible for a different UI element. The Swing GUI system, for example, models almost all interface components as individual MVC systems.
MVC is often seen in web applications where the view is the HTML or XHTML generated by the app. The controller receives GET or POST input and decides what to do with it, handing over to domain objects (i.e. the model) that contain the business rules and know how to carry out specific tasks such as processing a new subscription, and which hand control to (X)HTML-generating components such as templating engines, XML pipelines, Ajax callbacks, etc.
The model is not necessarily merely a database; the 'model' in MVC is both the data and the business/domain logic needed to manipulate the data in the application. Many applications use a persistent storage mechanism such as a database to store data. MVC does not specifically mention the data access layer because it is understood to be underneath or encapsulated by the model. Models are not data access objects; however, in very simple apps that have little domain logic there is no real distinction to be made. Active Record is an accepted design pattern that merges domain logic and data access code — a model which knows how to persist itself.

Architecture vs. frameworks

Although MVC is typically associated with frameworks, it is essentially an architecture.[6] This means that it can be implemented even without an object-oriented language or a specific class hierarchy. For example, using as little as jQuery's trigger() and bind(), it is possible to build robust MVC applications in a browser using Javascript. The key is simply to divide up the responsibilities of the MVC components into clearly defined sections of code. As stated in the overview, the code that embodies the model takes care of state, business logic, persistence, and notifications. The persistence can be implemented via cookies or AJAX. The notifications can be taken care of by the jQuery.trigger(). The code that embodies the view takes care of querying the model and rendering the view. The view code can be implemented in a variety of ways, including inserting HTML DOM nodes or changing CSS styles. The code that embodies the controller takes care of initialization of the model and wiring up the events between the view's HTML DOM elements and controller and between the model and the view code, using jQuery.bind().

Example

Model
The model is a collection of Java classes that form a software application intended to store, and optionally separate, data. A single front end class that can communicate with any user interface (for example: a console, a graphical user interface, or a web application).
View
The view is represented by a JavaServer Page, with data being transported to the page in the HttpServletRequest or HttpSession.
Controller
The Controller servlet communicates with the front end of the model and loads the HttpServletRequest or HttpSession with appropriate data, before forwarding the HttpServletRequest and Response to the JSP using a RequestDispatcher.

Implementations of MVC as GUI frameworks
  • GNUstep, also based on OpenStep, encourages MVC as well.
  • GTK+ provides models (as both interfaces and as concrete implementations) and views, while clients implement the controllers through signals.
  • JFace.
  • Qt since Qt4 release.
  • Java Swing.
  • Apache Pivot.
  • Adobe Flex with the Cairngorm Framework.


















2011年8月11日星期四

Python: datetime

The datetime module supplies classes for manipulating dates and times in both simple and complex ways.

Available Types

class datetime.date
An idealized naive date, assuming the current Gregorian calendar always was, and always will be, in effect. Attributes: year, month, and day.

class datetime.time
An idealized time, independent of any particular day, assuming that every day has exactly 24*60*60 seconds (there is no notion of “leap seconds” here). Attributes: hour, minute, second, microsecond, and tzinfo.

class datetime.datetime
A combination of a date and a time. Attributes: year, month, day, hour, minute, second, microsecond, and tzinfo.

class datetime.timedelta
A duration expressing the difference between two date, time, or datetime instances to microsecond resolution.

class datetime.tzinfo
An abstract base class for time zone information objects. These are used by the datetime and time classes to provide a customizable notion of time adjustment (for example, to account for time zone and/or daylight saving time).

timedelta Objects
class datetime.timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]]]]]]])

>>> from datetime import timedelta
>>> d = timedelta(microseconds=-1)
>>> (d.days, d.seconds, d.microseconds)
(-1, 86399, 999999)



AttributeValue
daysBetween -999999999 and 999999999 inclusive
secondsBetween 0 and 86399 inclusive
microsecondsBetween 0 and 999999 inclusive


date Objects
class datetime.date(year, month, day)

datetime Objects
class datetime.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])


Supported operations:
OperationResult
datetime2 = datetime1 + timedelta(1)
datetime2 = datetime1 - timedelta(2)
timedelta = datetime1 - datetime2(3)
datetime1 < datetime2Compares datetime to datetime. (4)


Some class methos:

datetime.strftime(format)
Return a string representing the date and time, controlled by an explicit format string. See section strftime() and strptime() Behavior.

The following is a list of all the format codes that the C standard (1989 version) requires, and these work on all platforms with a standard C implementation. Note that the 1999 version of the C standard added additional format codes.

DirectiveMeaningNotes
%aLocale’s abbreviated weekday name.
%ALocale’s full weekday name.
%bLocale’s abbreviated month name.
%BLocale’s full month name.
%cLocale’s appropriate date and time representation.
%dDay of the month as a decimal number [01,31].
%fMicrosecond as a decimal number [0,999999], zero-padded on the left(1)
%HHour (24-hour clock) as a decimal number [00,23].
%IHour (12-hour clock) as a decimal number [01,12].
%jDay of the year as a decimal number [001,366].
%mMonth as a decimal number [01,12].
%MMinute as a decimal number [00,59].
%pLocale’s equivalent of either AM or PM.(2)
%SSecond as a decimal number [00,61].(3)
%UWeek number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.(4)
%wWeekday as a decimal number [0(Sunday),6].
%WWeek number of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Monday are considered to be in week 0.(4)
%xLocale’s appropriate date representation.
%XLocale’s appropriate time representation.
%yYear without century as a decimal number [00,99].
%YYear with century as a decimal number.
%zUTC offset in the form +HHMM or -HHMM (empty string if the the object is naive).(5)
%ZTime zone name (empty string if the object is naive).
%%A literal '%' character.