2015年4月24日 星期五

繩子長度與重量單位換算表

繩子長度單位:
1 台丈 = 10台尺 ≒ 3.\overline{03}公尺
1 台尺(日尺)[4] = (10/33) 公尺[5]0.\overline{30}公尺
1 台寸 = 0.1台尺 ≒ 0.\overline{03}公尺

繩徑單位(英吋、分):1英吋 = 8分,一分≒ 3.175mm


B級特多龍繩長度重量換算表
繩子粗細//mm
每公斤長度/m
每捆重量/kg
備註
1.2/4mm
40
15

1.5/5mm
35
15

1.8/5.5mm
21
16

2/6mm
16
22

3/9mm
11
23

3.5/10mm
9.5
25

4/12mm
8
37

4.5/14mm
6
50

5/15mm
4.5
50

6/18mm
3.5
64

     通常到了零售商繩子會再整理裁切,所以每捆重量不一,此表僅供參考。


Reference:

2015年4月23日 星期四

Ubuntu: Install FirefoxNewVersion/MozillaBuilds

Ubuntuzilla repository

An easy way of installing a Mozilla build is to use the Ubuntuzilla project repository. Ubuntuzilla is for ordinary users that want to use the latest Mozilla build as their default browser.
The Ubuntuzilla project's repository contains .deb repacks of the unmodified official Mozilla builds of Firefox, Thunderbird, and SeaMonkey. Just add the repository to your sources, and you'll be kept up to date on the latest Mozilla releases through the package manager. 
See the Ubuntuzilla website for details and usage instructions.

Installation

Old ubuntuzilla installer script users note: before installing these packages, run "ubuntuzilla.py -a remove -p packagename". Otherwise installation may fail due to the existence of a local diversion of /usr/bin/ links, placed there by the old ubuntuzilla script.
  • It is strongly recommended to make a backup of your Firefox/Thunderbird/Seamonkey user profile, just in case. This is stored in your home directory. Firefox and Seamonkey profiles are stored in the .mozilla directory, Thunderbird profile is stored in .thunderbird or.mozilla-thunderbird directory.
  • Add the ubuntuzilla repository to your /etc/apt/sources.list, either using your favorite editor, or by running the provided one-line command (copy and paste the entire line into a terminal, then press enter).
The repository to add, if you're adding it manually to your sources.list, is
deb http://downloads.sourceforge.net/project/ubuntuzilla/mozilla/apt all main
If you wish, verify that the repository has been added, by looking at /etc/apt/sources.list in your favorite text editor, or running "tail /etc/apt/sources.list" in the terminal.
  • Then add the package signing key to your keyring, by running the following command:
    sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com C1289A29
  • Update your package database:
    sudo apt-get update
  • Install your desired package, with one of the following commands:
    sudo apt-get install firefox-mozilla-build
    sudo apt-get install thunderbird-mozilla-build
    sudo apt-get install seamonkey-mozilla-build
All of this can also be done through the GUI with the Synaptic Package Manager, if you so desire. See this step-by-step visual tutorialif you would like to try the GUI approach.
From here on, any updates will be offered to you through the usual channels in the Update Manager.

Localizations

The packages in the repos are 'en-US' (US English) versions. To install any other translations:
  • Download the appropriate language pack add-on .xpi file,
  • Install it from within Firefox/Thunderbird/Seamonkey (as you would with any other add-on).
  • Enable it by setting the config general.useragent.locale to the name of the locale that you want to use. The name of the locale is the same as the name of the language pack that you installed.
    • To edit the config, go to Edit -> Preferences -> Advanced -> General -> Config Editor.
  • Restart the application for the setting to take effect.
Firefox language packs are at
http://releases.mozilla.org/pub/mozilla.org/firefox/releases/<version>/linux-i686/xpi/
Thunderbird language packs are at
http://releases.mozilla.org/pub/mozilla.org/thunderbird/releases/<version>/linux-i686/xpi/
Seamonkey language packs are at
http://releases.mozilla.org/pub/mozilla.org/seamonkey/releases/<version>/langpack/
For more info about installing language packs, see this Mozilla knowledgebase article.

Removal

To uninstall the packages, uninstall the *-mozilla-build packages, using your favorite package manager. E.g., using apt-get:
sudo apt-get remove firefox-mozilla-build
sudo apt-get remove thunderbird-mozilla-build
sudo apt-get remove seamonkey-mozilla-build
If you no longer wish to have the Ubuntuzilla repository in your sources, you can edit it out of your /etc/apt/sources.list.

Reference:

Ubuntu: Modify the Dependency of a package (*CAUTION* THIS MAY BREAK THE SYSTEM UNINTENTIONALLY)

*CAUTION* THIS MAY BREAK THE SYSTEM UNINTENTIONALLY


Search packages on:
http://packages.ubuntu.com/
http://www.ubuntuupdates.org/
http://www.debian.org/distrib/packages

1. Extracts the filesystem tree:
  $ dpkg -x original.deb data
2. Extracts the control information (default to DEBIAN/):
  $ dpkg -e original.deb
3. Edit the dependency of the packages:
  $ vi DEBIAN/control
  $ mv DEBIAN data/
4. Create a new debian archive:
  $ dpkg -b data new.deb
5. Install the new package:
  $ sudo dpkg -i new.deb


If some dependency issues still occurred, dpkg may suggest you to use "--auto-deconfigure" to solve those issue. *CAUTION* THIS MAY ALSO BREAK THE DEPENDENCY OF OTHER INSTALLED PACKAGES.
If the dependency is broken after using the "--auto-deconfigure" option, try the following commands to fix it:
Reinstall the original version of some packages which break the dependency:
  $ sudo apt-get install package=x.y.z-m.n
Use "-f / --fix-broken" option in apt-get:
  $ sudo apt-get -f install package
    OR (if still unable to correct the problem, but may be a LOT of works to do.)
  $ sudo apt-get -f install

2015年4月22日 星期三

C++: vector v.s. deque

std::vector

template < class T, class Alloc = allocator<T> > class vector; // generic template
Vector


Vectors are sequence containers representing arrays that can change in size.

Just like arrays, vectors use contiguous storage locations for their elements, which means that their elements can also be accessed using offsets on regular pointers to its elements, and just as efficiently as in arrays. But unlike arrays, their size can change dynamically, with their storage being handled automatically by the container.

Internally, vectors use a dynamically allocated array to store their elements. This array may need to be reallocated in order to grow in size when new elements are inserted, which implies allocating a new array and moving all elements to it. This is a relatively expensive task in terms of processing time, and thus, vectors do not reallocate each time an element is added to the container.

Instead, vector containers may allocate some extra storage to accommodate for possible growth, and thus the container may have an actual capacity greater than the storage strictly needed to contain its elements (i.e., its size). Libraries can implement different strategies for growth to balance between memory usage and reallocations, but in any case, reallocations should only happen at logarithmically growing intervals of size so that the insertion of individual elements at the end of the vector can be provided with amortized constant time complexity (see push_back).

Therefore, compared to arrays, vectors consume more memory in exchange for the ability to manage storage and grow dynamically in an efficient way.

Compared to the other dynamic sequence containers (deques, lists and forward_lists), vectors are very efficient accessing its elements (just like arrays) and relatively efficient adding or removing elements from its end. For operations that involve inserting or removing elements at positions other than the end, they perform worse than the others, and have less consistent iterators and references than lists and forward_lists.

std::deque

template < class T, class Alloc = allocator<T> > class deque;
Double ended queue
deque (usually pronounced like "deck") is an irregular acronym of double-ended queue. Double-ended queues are sequence containers with dynamic sizes that can be expanded or contracted on both ends (either its front or its back).

Specific libraries may implement deques in different ways, generally as some form of dynamic array. But in any case, they allow for the individual elements to be accessed directly through random access iterators, with storage handled automatically by expanding and contracting the container as needed.

Therefore, they provide a functionality similar to vectors, but with efficient insertion and deletion of elements also at the beginning of the sequence, and not only at its end. But, unlike vectors, deques are not guaranteed to store all its elements in contiguous storage locations: accessing elements in a deque by offsetting a pointer to another element causes undefined behavior.

Both vectors and deques provide a very similar interface and can be used for similar purposes, but internally both work in quite different ways: While vectors use a single array that needs to be occasionally reallocated for growth, the elements of a deque can be scattered in different chunks of storage, with the container keeping the necessary information internally to provide direct access to any of its elements in constant time and with a uniform sequential interface (through iterators). Therefore, deques are a little more complex internally than vectors, but this allows them to grow more efficiently under certain circumstances, especially with very long sequences, where reallocations become more expensive.

For operations that involve frequent insertion or removals of elements at positions other than the beginning or the end, deques perform worse and have less consistent iterators and references than lists and forward lists.
 
Reference:
http://www.cplusplus.com/reference/vector/vector/?kw=vector
http://www.cplusplus.com/reference/deque/deque/?kw=deque
GotW #54: Using Vector and Deque

2015年4月21日 星期二

Git Usage

Git Basics

Git Commands
git clone
git pull
  --rebase: Instead of a merge, perform a rebase after fetching.
git push
git remote
  -v, --verbose
  set-url <name> <url>

git log
git diff
git tag
  -a <tagname> <commit>
git describe
git status
git-rev-parse

git add
git rm
git mv
git reset
git revert
git commit
  --ammend*
  Git 版本控制系統(3) 還沒 push 前可以做的事

git branch
  branch: create a new branch.
  -d branch: Delete a branch. The branch must be fully merged in HEAD.
  -D branch: Delete a branch irrespective of its merged status.
git checkout
  branch: switch to branch
  path: discard changes on working copy
git merge
git rebase
  branch: Forward-port local commits base on the branch.
  Git 分支 - 分支的新建與合併
  Git Branch 的操作與基本工作流程
  使用 git rebase 避免無謂的 merge
  Pull with rebase

2015年4月17日 星期五

ANSI escape code

Colors

Text colors (and SGR parameters in general) are manipulated using CSI n1 [;n2 [; ...]] m sequences, where each n1, n2, ... is an SGR parameter as shown above. Thus, for instance, you use codes 30+i to specify foreground color, 40+i to specify background color, where i is the number in the desired color's column header in the table below. The following examples can be used with the printf utility, where \x1b[ implements the CSI: To switch the foreground color to black, use \x1b[30m; to switch to red, use \x1b[31m; utilizing the "bold" parameter, gray would be \x1b[30;1m; to get bold red, use \x1b[31;1m. To reset colors to their defaults, use \x1b[39;49m (or reset all attributes with \x1b[0m).
Color table[11]
Intensity 0 1 2 3 4 5 6 7
Normal Black Red Green Yellow[12] Blue Magenta Cyan White
Bright Black Red Green Yellow Blue Magenta Cyan White
There are two other color standards CSS/HTML standard colors and X Window colors which standardize both the color names and associated RGB color values, but the escape sequence standard only specifies the color names, not RGB values. The chart below shows default RGB assignments for some common terminal programs, together with the CSS and the X Window System colors for these color names.[citation needed]

Color name Standard VGA colors Windows XP CMD Terminal.app PuTTY mIRC xterm CSS/HTML X
Normal Black 0, 0, 0 0, 0, 0 0, 0, 0 0, 0, 0 0, 0, 0 0, 0, 0 0, 0, 0 0, 0, 0
Red 170, 0, 0 128, 0, 0 194, 54, 33 187, 0, 0 127, 0, 0 205, 0, 0 255, 0, 0 255, 0, 0
Green 0, 170, 0 0, 128, 0 37, 188, 36 0, 187, 0 0, 147, 0 0, 205, 0 0, 255, 0 0, 128, 0
Brown/yellow 170, 85, 0 128, 128, 0 173, 173, 39 187, 187, 0 252, 127, 0 205, 205, 0 255, 255, 0 255, 255, 0
Blue 0, 0, 170 0, 0, 128 73, 46, 225 0, 0, 187 0, 0, 127 0, 0, 238 0, 0, 255 0, 0, 255
Magenta 170, 0, 170 128, 0, 128 211, 56, 211 187, 0, 187 156, 0, 156 205, 0, 205 255, 0, 255 255, 0, 255
Cyan 0, 170, 170 0, 128, 128 51, 187, 200 0, 187, 187 0, 147, 147 0, 205, 205 0, 255, 255 0, 255, 255
Gray 170, 170, 170 192, 192, 192 203, 204, 205 187, 187, 187 210, 210, 210 229, 229, 229 255, 255, 255 255, 255, 255
Bright/light Darkgray 85, 85, 85 128, 128, 128 129, 131, 131 85, 85, 85 127, 127, 127 127, 127, 127

Red 255, 85, 85 255, 0, 0 252,57,31 255, 85, 85 255, 0, 0 255, 0, 0

Green 85, 255, 85 0, 255, 0 49, 231, 34 85, 255, 85 0, 252, 0 0, 255, 0 144, 238, 144 144, 238, 144
Yellow 255, 255, 85 255, 255, 0 234, 236, 35 255, 255, 85 255, 255, 0 255, 255, 0 255, 255, 224 225, 255, 224
Blue 85, 85, 255 0, 0, 255 88, 51, 255 85, 85, 255 0, 0, 252 92, 92, 255 173, 216, 230 173, 216, 230
Magenta 255, 85, 255 255, 0, 255 249, 53, 248 255, 85, 255 255, 0, 255 255, 0, 255

Cyan 85, 255, 255 0, 255, 255 20, 240, 240 85, 255, 255 0, 255, 255 0, 255, 255 224, 255, 255 224, 255, 255
White 255, 255, 255 255, 255, 255 233, 235, 235 255, 255, 255 255, 255, 255 255, 255, 255



Reference:
http://en.wikipedia.org/wiki/ANSI_escape_code

2015年4月14日 星期二

Github Usage

Change the repository URL of local working copy:
View the current origin URL:
$ git remote -v
$ git remote set-url origin https://github.com/<user>/<repo>.git

If you try to access the repository (clone, push, ...etc) via HTTP/HTTPS, the following error occurred:
error: The requested URL returned error: 403 while accessing https://github.com/user/repo.git/info/refs
fatal: HTTP request failed
Use SSH (get the URL from the repository):
$ git remote set-url origin git@github.com:<user>/<repo>.git



Connecting over SSH
If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub.

Note: you can use the ~/.ssh/config to setup the SSH authentication instead of ssh-agent


Template of .gitignore
https://github.com/github/gitignore


Reference:
https://help.github.com/set-up-git-redirect
https://help.github.com/create-a-repo
https://help.github.com/articles/fork-a-repo/
https://help.github.com/articles/https-cloning-errors/

https://help.ubuntu.com/lts/serverguide/git.html