I am LAZY bones ? all linux

2007年 09月 的归档

搞定tty下的mplayer的中文字幕乱码问题

没有X,只在tty下用fbdev看电影的朋友适用.其他看情况.
ubuntu的话安装ttf-arphic-uming这个字体包就会有如下字体文件了,不然的话也可以用其他字体试试.
下面两句是自定义字幕的文字大小用的.

引用:
$ cat .mplayer/config
# Write your default config options here!
font=/usr/share/fonts/truetype/arphic/uming.ttf
subcp=cp936
subfont-autoscale=0
subfont-text-scale=20

Internet Archive 免费的音乐/电影/图片/软件

网址: http://www.archive.org

引用:
The Internet Archive is a 501(c)(3) non-profit that was founded to build an Internet library, with the purpose of offering permanent access for researchers, historians, and scholars to historical collections that exist in digital format. Founded in 1996 and located in the Presidio of San Francisco, the Archive has been receiving data donations from Alexa Internet and others. In late 1999, the organization started to grow to include more well-rounded collections. Now the Internet Archive includes texts, audio, moving images, and software as well as archived web pages in our collections.

用户管理(命令行)

添加一个xxx用户:

代码:
useradd xxx

添加一个xxx用户,指定家目录为/home/xxx :

代码:
useradd -m -d /home/xxx xxx

添加一个xxx用户,指定家目录为/home/xxx ,并指定用bash :

代码:
useradd -m -d /home/xxx -s /bin/bash xxx

添加一个xxx用户,指定家目录为/home/xxx ,并指定用bash,同时加入yyy和zzz组(默认的xxx组也是保留的) :

代码:
useradd -m -d /home/xxx -s /bin/bash -G yyy,zzz xxx

查看有xxx用户参与的组:

代码:
id xxx

将xxx用户加入yyy组和zzz组:

代码:
usermod -G yyy,zzz xxx

将xxx用户的默认shell改为dash:

代码:
usermod -s /bin/dash xxx

删除xxx用户:

代码:
userdel xxx

删除xxx用户,连同家目录一起删除:

代码:
userdel -r xxx

以上命令除 id xxx 外都需要root权限.

中秋快乐~~~

中秋快乐~~~

我的compiz终于又好用了.

哈哈,今天升级了一下,compiz终于又恢复正常了,之前也是因为升级,导致compiz罢工.出现个什么core dump,我把.gconf里面的相应配置都删关了也还是不行,而且几个更新都没有解决我的问题,还真是郁闷了好久,今天终于又重见天日了,awn也可以工作起来了,爽啊~~

在线生成 favicon.ico

http://www.html-kit.com/favicon/

awk手册 简体中文版 制作中

敬请期待…

=====补充=====
现在已经完成: http://linuxfire.com.cn/~lily/awk.html

gedit增加个外部工具,转换文本为windows格式。

大家应该知道,换行符在每个操作系统中是不一样的,比如windows是0x0d,0x0a,linux是0x0a,mac是0x0d。
这样就导致各操作系统间的文本交流出现了一点不大不小的问题,虽然windows和linux下的大部分编辑器都会知道识别这个差异,并进行相应的转换,但是像windows中的记事本这类老古董就不会了。。。。而且据说windows中用记事本的不在少数。。。所以,在linux下创建的文本文件,到了windows中用记事本一打开,就会发现所有的换行符都变成了黑方块 Laughing
不过既然知道了原理,解决起来当然是相当地方便:gedit(我的版本是 2.18.1)已经可以支持自定义的外部工具了,还可以给每个外部工具定义一个快捷键,可谓相当方便。于是就在工具-外部工具里面新建一条:名字自己取,命令如下:

代码:
#!/bin/sh
tr “\n” “\r” | sed ‘s/\r/\r\n/g’

输入选择当前文档,输出选择替换当前文档。
不过我这个版本的gedit似乎有个小bug,就是选择了输出之后不会自动保存,想了个另外的办法:在~/.gnome2/gedit/tools目录下新建一个文件(文件名随便,不过记得加可执行权限 chmod +x 文件名)内容如下:

引用:
#!/bin/sh# [Gedit Tool]
# Comment=转换为windows格式
# Name=转换为windows格式
# Shortcut=F10
# Applicability=all
# Output=replace-document
# Input=document

tr “\n” “\r” | sed ‘s/\r/\r\n/g’

这个和上面说的方法其实是一样的,只不过可以避免gedit的bug。完成了以后gedit的工具菜单里面就会多出一项。然后linux下编辑好文本以后再执行一下,再保存,windows的朋友就可以轻松打开你的文件了。

本例其实很简单,主要是研究下gedit的自定义外部工具功能。 Laughing

用lighttpd代替apache2

卸载:

代码:
sudo apt-get remove apache2

这样会提示要卸载很多软件,包括php和phpmyadmin等等,不想卸载这些的话,可以试试

代码:
sudo aptitude remove apache2

,不过其实那些先卸了也不要紧,反正缓存里面有deb包的,呆会儿再装上也不费力。
安装:

代码:
sudo apt-get install lighttpd php phpmyadmin

配置:
这样换了以后,php的配置文件变成:
/etc/php5/cgi/php.ini
lighttpd的配置文件在:
/etc/lighttpd/lighttpd.conf

好处就是省几M内存,速度暂时还没感觉出来。

[转帖]一位程序员的演变历程

来源: http://sunsite.nus.edu.sg/pub/humour/prog-evolve.html

The Evolution of a Programmer
High School/Junior High

代码:
10 PRINT “HELLO WORLD”
20 END

First year in College

代码:
program Hello(input, output)
begin
writeln(‘Hello World’)
end.

Senior year in College

代码:
(defun hello
(print
(cons ‘Hello (list ‘World))))

New professional

代码:
#include <stdio.h>
void main(void)
{
char *message[] = {“Hello “, “World”};
int i;

for(i = 0; i < 2; ++i)
printf(“%s”, message[i]);
printf(“\n”);
}

Seasoned professional

代码:
#include <iostream.h>
#include <string.h>

class string
{
private:
int size;
char *ptr;

public:
string() : size(0), ptr(new char(”)) {}

string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}

~string()
{
delete [] ptr;
}

friend ostream &operator <<(ostream &, const string &);
string &operator=(const char *);
};

ostream &operator<<(ostream &stream, const string &s)
{
return(stream << s.ptr);
}

string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}

int main()
{
string str;

str = “Hello World”;
cout << str << endl;

return(0);
}

Master Programmer

代码:
[
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]
library LHello
{
// bring in the master library
importlib(“actimp.tlb”);
importlib(“actexp.tlb”);

// bring in my interfaces
#include “pshlo.idl”

[
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotype THello
{
interface IHello;
interface IPersistFile;
};
};

[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
module CHelloLib
{

// some code related header files
importheader();
importheader();
importheader();
importheader(“pshlo.h”);
importheader(“shlo.hxx”);
importheader(“mycls.hxx”);

// needed typelibs
importlib(“actimp.tlb”);
importlib(“actexp.tlb”);
importlib(“thlo.tlb”);

[
uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
aggregatable
]
coclass CHello
{
cotype THello;
};
};

#include “ipfix.hxx”

extern HANDLE hEvent;

class CHello : public CHelloBase
{
public:
IPFIX(CLSID_CHello);

CHello(IUnknown *pUnk);
~CHello();

HRESULT __stdcall PrintSz(LPWSTR pwszString);

private:
static int cObjRef;
};

#include <windows.h>
#include <ole2.h>
#include <stdio.h>
#include <stdlib.h>
#include “thlo.h”
#include “pshlo.h”
#include “shlo.hxx”
#include “mycls.hxx”

int CHello::cObjRef = 0;

CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
{
cObjRef++;
return;
}

HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString)
{
printf(“%ws\n”, pwszString);
return(ResultFromScode(S_OK));
}

CHello::~CHello(void)
{

// when the object count goes to zero, stop the server
cObjRef–;
if( cObjRef == 0 )
PulseEvent(hEvent);

return;
}

#include <windows.h>
#include <ole2.h>
#include “pshlo.h”
#include “shlo.hxx”
#include “mycls.hxx”

HANDLE hEvent;

int _cdecl main(
int argc,
char * argv[]
) {
ULONG ulRef;
DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();

hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

// Initialize the OLE libraries
CoInitializeEx(NULL, COINIT_MULTITHREADED);

CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE, &dwRegistration);

// wait on an event to stop
WaitForSingleObject(hEvent, INFINITE);

// revoke and release the class object
CoRevokeClassObject(dwRegistration);
ulRef = pCF->Release();

// Tell OLE we are going away.
CoUninitialize();

return(0); }

extern CLSID CLSID_CHello;
extern UUID LIBID_CHelloLib;

CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
0x2573F891,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};

UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
0x2573F890,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};

#include <windows.h>
#include <ole2.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include “pshlo.h”
#include “shlo.hxx”
#include “clsid.h”

int _cdecl main(
int argc,
char * argv[]
) {
HRESULT hRslt;
IHello *pHello;
ULONG ulCnt;
IMoniker * pmk;
WCHAR wcsT[_MAX_PATH];
WCHAR wcsPath[2 * _MAX_PATH];

// get object path
wcsPath[0] = ”;
wcsT[0] = ”;
if( argc > 1) {
mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
wcsupr(wcsPath);
}
else {
fprintf(stderr, “Object path must be specified\n”);
return(1);
}

// get print string
if(argc > 2)
mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
else
wcscpy(wcsT, L”Hello World”);

printf(“Linking to object %ws\n”, wcsPath);
printf(“Text String %ws\n”, wcsT);

// Initialize the OLE libraries
hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);

if(SUCCEEDED(hRslt)) {

hRslt = CreateFileMoniker(wcsPath, &pmk);
if(SUCCEEDED(hRslt))
hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);

if(SUCCEEDED(hRslt)) {

// print a string out
pHello->PrintSz(wcsT);

Sleep(2000);
ulCnt = pHello->Release();
}
else
printf(“Failure to connect, status: %lx”, hRslt);

// Tell OLE we are going away.
CoUninitialize();
}

return(0);
}

Apprentice Hacker

代码:
#!/usr/local/bin/perl
$msg=”Hello, world.\n”;
if ($#ARGV >= 0) {
while(defined($arg=shift(@ARGV))) {
$outfilename = $arg;
open(FILE, “>” . $outfilename) || die “Can’t write $arg: $!\n”;
print (FILE $msg);
close(FILE) || die “Can’t close $arg: $!\n”;
}
} else {
print ($msg);
}
1;

Experienced Hacker

代码:
#include <stdio.h>
#define S “Hello, World\n”
main(){exit(printf(S) == strlen(S) ? 0 : 1);}

Seasoned Hacker

代码:
% cc -o a.out ~/src/misc/hw/hw.c
% a.out

Guru Hacker

代码:
% cat
Hello, world.
^D

New Manager

代码:
10 PRINT “HELLO WORLD”
20 END

Middle Manager

代码:
mail -s “Hello, world.” bob@b12
Bob, could you please write me a program that prints “Hello,
world.”?
I need it by tomorrow.
^D

Senior Manager

代码:
% zmail jim
I need a “Hello, world.” program by this afternoon.

Chief Executive

代码:
% letter
letter: Command not found.
% mail
To: ^X ^F ^C
% help mail
help: Command not found.
% damn!
!: Event unrecognized
% logout

High School/Junior High 高中阶段是 basic
First year in College 到了大一 成了pascal
Senior year in College 大二成了 lisp,这个比较少见
New professional 是C
Seasoned professional 成了C++
Master Programmer 这个我也还不确定,不过应该是传说中的 C#
Apprentice Hacker 是perl,没得说了
Experienced Hacker 还是C,不过水平显然不一样了
Seasoned Hacker 只会编译了。。。
Guru Hacker 直接用现成的工具了
New Manager 回归basic了
Middle Manager 发个邮件给手下,说明天要个程序
Senior Manager 邮件更简单了,直接下午要
Chief Executive 不会打命令了,经常打错,后来直接logout了,估计直接找手下对话去了。。。。