VM
@name
@os
@disk
@ram
Disk
@size (MB)
Sunday, 5 December 2010
Monday, 29 November 2010
Trash folder in ubuntu
It might be a good idea to set the default download folder of the browser to be the trash folder, so that you can quickly empty the folder. In ubuntu, the trash folder is in [user home dir]/.local/share/Trash/files.
Labels:
tips
Sunday, 28 November 2010
Chinese to English Translation
1. 蜂胶: Propolis ([ˈprɔpəlis]), resinous mixture that honey bees collect from tree buds, sap flows, or other botanical sources. It is used as a sealant for unwanted open spaces in the hive.
2. 皮蛋: Preserved egg
3. 分散圈:Circle of confusion [photography]
2. 皮蛋: Preserved egg
3. 分散圈:Circle of confusion [photography]
Labels:
english
Tuesday, 23 November 2010
git usages
1. Fixing un-committed mistakes
If git reset takes a commit name as its parameter, it sets the current head to the specified commit and optionally resets the index and working tree to match. It defaults to HEAD (a keyword that refers to the most recent commit to the branch you're in).
Use --soft option when you want to stage all the previous commits but not commit them. This gives you a chance to modify the previous commit by adding to or taking away from it.
With --hard, it removes the commit from your repository and from your working tree. It's the equivalent of a delete button on your repository with no "undo". It's like the commit never happened, so it should be used with care.
2. Fixing commits
3. Reset and checkout
This means that git reset paths is the opposite of git add paths.
After running git reset paths to update the index entry, you can use git-checkout(1) to check the contents out of the index to the working tree. Alternatively, using git-checkout(1) and specifying a commit, you can copy the contents of a path out of a commit to the index and to the working tree in one go.
So generally, use git checkout paths to revert changes in the working tree and use git reset paths to unstage changes.
A good explanation of
4. Tracking remote branch
Tracking when creating a new branch:
The full syntax is:
$ git reset --hard HEADThis will throw away any changes you may have added to the git index and as well as any outstanding changes you have in your working tree.
If git reset takes a commit name as its parameter, it sets the current head to the specified commit and optionally resets the index and working tree to match. It defaults to HEAD (a keyword that refers to the most recent commit to the branch you're in).
Use --soft option when you want to stage all the previous commits but not commit them. This gives you a chance to modify the previous commit by adding to or taking away from it.
With --hard, it removes the commit from your repository and from your working tree. It's the equivalent of a delete button on your repository with no "undo". It's like the commit never happened, so it should be used with care.
2. Fixing commits
$ git commit --amend -C HEADThis amends the previous commit, and keeps the same log message. "-C commit" takes an existing commit object, and reuses the log message and the authorship information when creating the commit.
3. Reset and checkout
$ git reset [commit] [--] pathWith a path parameter, git reset resets the index entries for all paths to their state at [commit]. (It does not affect the working tree, nor the current branch.)
This means that git reset paths is the opposite of git add paths.
After running git reset paths to update the index entry, you can use git-checkout(1) to check the contents out of the index to the working tree. Alternatively, using git-checkout(1) and specifying a commit, you can copy the contents of a path out of a commit to the index and to the working tree in one go.
So generally, use git checkout paths to revert changes in the working tree and use git reset paths to unstage changes.
A good explanation of
reset and, its difference with checkout is here.
4. Tracking remote branch
Tracking when creating a new branch:
The full syntax is:
$ git checkout -track -b [local branch] [remote]/[tracked branch]Simpler version is:
$ git checkout -t origin/branchSetting up tracking for an existing branch:
& git branch --set-upstream branch upstream/branch
Labels:
git
Thursday, 14 October 2010
Model View Controller
MVC provides a good abstraction and framework for combining GUI and the underlying application logic. However, different frameworks provides slightly different infrastructure for implementing MVC. Here's a summary of them.
Ruby on Rails:
Ruby on Rails:
You can implement a similar framework in Java:
- Model - The model represents data and the rules that govern access to and updates of this data. In enterprise software, a model often serves as a software approximation of a real-world process.
- View - The view renders the contents of a model. It specifies exactly how the model data should be presented. If the model data changes, the view must update its presentation as needed. This can be achieved by using a push model, in which the view registers itself with the model for change notifications, or a pull model, in which the view is responsible for calling the model when it needs to retrieve the most current data.
- Controller - The controller translates the user's interactions with the view into actions that the model will perform. In a stand-alone GUI client, user interactions could be button clicks or menu selections, whereas in an enterprise web application, they appear as
GETandPOSTHTTP requests. Depending on the context, a controller may also select a new view -- for example, a web page of results -- to present back to the user.
Interaction Between MVC Components
- The view registers as a listener on the model. Any changes to the underlying data of the model immediately result in a broadcast change notification, which the view receives. This is an example of the push model described earlier. Note that the model is not aware of the view or the controller -- it simply broadcasts change notifications to all interested listeners.
- The controller is bound to the view. This typically means that any user actions that are performed on the view will invoke a registered listener method in the controller class.
- The controller is given a reference to the underlying model.
Modifying the MVC Design
A more recent implementation of the MVC design places the controller between the model and the view. This design is common in the Apple Cocoa framework.
The primary difference between this design and the more traditional version of MVC is that the notifications of state changes in model objects are communicated to the view through the controller. Hence, the controller mediates the flow of data between model and view objects in both directions. View objects, as always, use the controller to translate user actions into property updates on the model. In addition, changes in model state are communicated to view objects through an application's controller objects.
Labels:
software engineering
Friday, 6 August 2010
Rusell Peters' Quote
"Chinese people and Indian people cannot do business together because Indian people can't get along without a bargain, and Chinese people cannot give you a bargain. Their objective is to get every penny from you. And ours is to keep every penny. There's a really bad power struggle there. I went to this Chinese mall. Some of you may know it - Pacific Mall. That's the wrong place for an Indian guy to go. I saw this bag; I want to buy this bag, I go to the Chinese guy behind the counter, 'How much?' He goes, [(In a Chinese accent)] 'Thirty-five dollars.' 'Um, How 'bout thirty?' And Chinese people will never tell you no. They'll tell you "no," the longest "no" you heard in your life, like you just said the most ridiculous thing they ever heard in their life. 'I'll give you thirty.' [(In a Chinese accent)] 'No-oooo. No-oooo. I can't do thirty dollars. I sell you thirty dollars today tomorrow you come I close down.'...[(In a Chinese accent)] 'Ok. You seem like nice guy. I give you best price. Thirty-four fifty.' I'm like, 'That's fifty cents, man.' [(In a Chinese accent)] 'Fifty cents is a lot of money. You save fifty cents here then maybe you somewhere else and you save another fifty cents, then you have one dollar. Then you take your dollar, you go to the dollar store, you buy something else.'"
Labels:
humor
Sunday, 1 August 2010
Hiking
Went hiking on Friday with the census team. We went to two trails: one is the San Andreas Fault Trail in Los Trancos Open Space Preserve; the other is the Stevens Creek Nature Trail in Monte Bello Open Space Preserve.
Subscribe to:
Posts
(
Atom
)