Nov 12
|
Action
|
apt-get command
|
aptitude command
|
|
Install foo
|
apt-get install foo
|
aptitude install foo
|
|
Search foo
|
apt-cache search foo
|
aptitude search foo
|
|
Remove foo
|
apt-get remove foo
|
aptitude remove foo
|
|
List reverse dependencies
|
apt-cache rdepends foo
|
aptitude ~D foo
|
|
Print information on priorities for foo
|
apt-cache policy foo
|
?
|
|
Download foo’s sources and build a binary .deb package
|
apt-get source –compile foo
|
?
|
How to upgrade your distribution
Find out current version of Debian that you are running:
Example for upgrading sarge to etch or etch 4.0r1 to 4.0r2 …etc
靘皞嚗Aptitude – Debian Wiki
Tagged with: cli • tips • Unix-like
Nov 12
箇 Leopard 批遣 Python 其璅∪銝銝剜憿
隞乩 MacPorts 鋆 Python 2.6嚗鋆憟賭敺箇
To fully complete your installation and make python 2.6 the default, please run
sudo port install python_select
sudo python_select python26
python_select嚗Switch the default python interpreter
隞斤扳瘝=.=
航芸楛雿蝯瘥頛靽
sudo ln -s /opt/local/bin/python python
Tagged with: cli • osx • Python • tips • Unix-like
Nov 05
tchinese.py
#!/bin/python
print "Python臬瑞拇"
python tchinese.py
SyntaxError: Non-ASCII character '\xe6' in file tchinese.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
航炊閮臭葉蝯圈蝭蝡嚗PEP 0263 — Defining Python Source Code Encodings
銝剜堆
To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file, such as:
or (using formats recognized by popular editors)
#!/usr/bin/python
# -*- coding: <encoding name> -*-
or
#!/usr/bin/python
# vim: set fileencoding=<encoding name> :
Example:
#!/bin/python
# -*- coding: utf-8 -*-
print "Python臬瑞拇"
Result:
Tagged with: CJKV • Programming • Python • tips • UTF-8
Nov 03
-h”Human-readable” output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte.
-sDisplay an entry for each specified file. (Equivalent to -d 0)
-ddepth
Display an entry for all files and directories depth directories deep.
芸箇桅憭批嚗
du -sh ~/Documents/EyeTV\ Archive/
3.2G /Users/name/Documents/EyeTV Archive/
箇桅鋆∟府撅斗瑼獢憭批嚗
du -sh ~/Documents/EyeTV\ Archive/*
4.0K /Users/name/Documents/EyeTV Archive/EyeTV Archive.xml
4.0K /Users/name/Documents/EyeTV Archive/EyeTVAutoTune.log
3.2G /Users/name/Documents/EyeTV Archive/勗葆擳 – 桀桀.eyetv
25M /Users/name/Documents/EyeTV Archive/隡蝝W拙 – 蝚17嗆脣怠⊿摮撅梯惇.eyetv
Tagged with: cli • tips • Unix-like
Nov 02
PHP 瑼獢
霈瑼:
1.fopen
蝭靘:
<?php
$handle = fopen("open_file.txt", "r");
if( $handle === FALSE)
{
echo "Open File Fail" . "<br>";
}
else
{
echo "Open File Success" . "<br>";
while (!feof($handle))
{
$current_line = fgets($handle);
echo $current_line . "<br>";
}
}
?>
2.file_get_contents
蝭靘:
<?php
$handle = file_get_contents('open_file.txt');
echo $handle;
?>
=========================================================
撖急:
1.fwrite
<?php
$handle = fopen('open_file.txt', 'w');
fwrite($handle, "test1");
fclose($fp);
?>
ps:fwrite 舀銵摮,憒閬銵敹銝 \n
2.file_put_contents
<?php
$handle = 'open_file.txt';
$current_line = "line1\n";
file_put_contents($handle, $current_line);
?>
source: PHP:瑼獢 @ 銝憭憭W劂銝 :: 摰a PIXNET ::
Tagged with: PHP • Programming • tips
Oct 26
嫣噶芸摰鋆
perl -MCPAN -e 'install full::module::name'
雿閰虫撟暹活敺摰寞 fetch ftp 靘皞 source code ∩嚗閬閰血嗾甈∼
蝺刻陌
tar xzvf example-<version>.tgz
cd example-<version>
perl Makefile.PL
make
make test
make install
撠WP::UserAgent璅∠
圈蝵宮pan
cpan> o conf init
cpan> reload index
撽霅摰鋆鈭瘝
perl -e 'require LWP::UserAgent'
update: 嚗舫閬 sudo 蝣箔甈撠瑼獢曉亦頂蝯
Tagged with: Perl • tips
啣