Monday, October 25, 2010
设置浏览器使用Foxit Reader打开PDF文件
Wednesday, August 25, 2010
Ubuntu 10.04 启动时黑屏问题【解决】
1. 症状
从9.10升级到10.04, 升级之后进入10.04之后,splash出现一会儿之后黑屏。使用Alt+Fx键等也无法切换到控制台。Ctr+Alt+Del也没有任何反应。只能手工关机重启。机器是toshiba笔记本 A50, 5年前的型号,显卡使用intel extreme X 内置显卡。
2. 原因
问题在于login画面显示上。虽然为黑屏,实际上是login画面,如果盲敲密码和回车的话,还是可以进入桌面的。问题出在了从splash切换到login画面时候显卡的mode设置上,可能一些老的显卡不工作。
3. 解决方法
修改启动参数,添加i915.modeset=1。
如果不行i915.modeset=0。
如果还不行xforcevesa。
任何一个如果可以正常启动,修改/etc/default/grub文件,找到GRUB_CMDLINE_LINUX_DEFAULT=“…”行,添加相应参数即可。
其他显卡以及其他解决方法,参考:
https://wiki.ubuntu.com/X/Bugs/Lucidi8xxFreezes
4. 注
好像该问题仅仅与2.6.32内核有关,如果其他方法不行,改换为2.6.31或者升级内核即可解决该问题。
Tuesday, July 13, 2010
Josephus问题求解
/*#include <iostream>
* Josephus问题:
* 设有n个人围坐一个圆桌周围,现从第1个人开始报数,数到第m的人出列,
* 然后从出列的下一个重新开始报数,数到第m的人又出列……如此重复,直
* 到所有的人全部出列为止。
* 对任意给定的n、m,求按出列次序得到的n个人员的顺序表。
*/
#include <sstream>
#include <list>
using namespace std;
int main(int argc, char** argv) {
if(argc != 3)
{
cout<<"Commandline parameter not correct!"<<endl;
exit(0);
}
int n=0, m=0;
stringstream ss;
ss<<argv[1];
ss>>n;
ss.clear();
ss<<argv[2];
ss>>m;
std::list<int> li;
for(int i=1;i<=n; ++i)
li.push_back(i);
while(li.size()>1)
{
for(int j=1;j<m; ++j)
{
++it;
if (it == li.end())
it = li.begin();
}
// output person who’s going to leave
cout<<*it<<endl;
it = li.erase(it); // erase return the next iterator
if(it==li.end())
it = li.begin();
}
// output last person
cout<<li.front()<<endl;
}
Saturday, November 8, 2008
XP remote desktop connection lost
I am using Windows XP SP3, and I connect to windows 2000 VPN server at work. After I use RDP to connect to my work PC for a while, then the connection is broken.
The error message is following:
The connection has been lost. Attempting to reconnect to your session...
2. Solution from internet
I googled and found a solution for using vista to connect to VPN server. It said that the following command will work.
netsh interface tcp set global autotuninglevel=disabled
But when I ran this on my XP box, I was prompted that command "interface tcp set global autotuninglevel=disabled" didn't exsit.
So this solution doesn't work for me.
3.My solution
Expand Options on the initial RDP screen. Then go to Advanced tab.
Click settings button and select do not use a TS gateway server radio butoon.
This setup seems work for me.
-
Tuesday, September 30, 2008
How to use wget to download globbing files
You tried wget http://www.server.com/dir/*.gif, but that didn't work
because HTTP retrieval does not support globbing.
In that case, use:
wget -r -l1 --no-parent -A.gif http://www.server.com/dir/
More verbose, but the effect is the same. -r -l1 means to retrieve
recursively, with maximum depth of 1. --no-parent means that refer-
ences to the parent directory are ignored, and -A.gif means to down-
load only the GIF files. -A "*.gif" would have worked too.
>>From mget manual.
You can use globbing for downloading globbing files from ftp servers.
wget ftp://ftp.server.com/dir/*.gif
--
Saturday, September 27, 2008
Intel Fortran relocation truncated to fit error: R_X86_64_32S against `baddr.0'
[*@hello src]$ uname -a
Linux nox 2.6.18-92.1.6.el5.centos.plus #1 SMP Thu Jun 26 12:18:07 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux
[*@hello src]$ cat /proc/cpuinfo
processor : 0
vendor_id : AuthenticAMD
cpu family : 16
model : 2
model name : Quad-Core AMD Opteron(tm) Processor 2354
stepping : 3
cpu MHz : 2210.898
cache size : 512 KB
physical id : 0
siblings : 4
core id : 0
cpu cores : 4
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 3dnowext 3dnow constant_tsc pni cx16 popcnt lahf_lm cmp_legacy svm extapic cr8_legacy altmovcr8 abm sse4a misalignsse 3dnowprefetch osvw
bogomips : 4424.74
TLB size : 1024 4K pages
clflush size : 64
cache_alignment : 64
address sizes : 48 bits physical, 48 bits virtual
power management: ts ttp tm stc 100mhzsteps hwpstate [8]
...(omission)
[*@hello src]$ ifort -V
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 10.1 Build 20080312 Package ID: l_fc_p_10.1.015
Copyright (C) 1985-2008 Intel Corporation. All rights reserved.
FOR NON-COMMERCIAL USE ONLY
2. Error message
[*@hello src]$ make
ifort -O2 -o Bcon_hr_cb4_cntl.exe bcon2ioapi.o read_mconc_nc.o vinterp.o vinterp_top.o hinterp.o makebdy.o get_hv_intp_top.o chemspec.o -L/opt/intel/fce/10.1.015/lib -lguide -lpthread -L/home/lin/local/ioapi-3.0/Linux2_x86_64ifort -lioapi -L/usr/local/netcdf-intel/lib -lnetcdf
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufintxd_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0x22): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufintx_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0x42a): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufdel3_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0x829): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0x83d): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufddt3d_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0x86d): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufddt3_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0xafe): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufxtr3d_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0xcd5): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufxtr3i_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0xeb1): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufxtr3_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0x108d): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufget3d_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0x1259): relocation truncated to fit: R_X86_64_32S against `baddr.0'
/home/lin/local/ioapi-3.0/Linux2_x86_64ifort/libioapi.a(bufint3.o): In function `bufget3i_':
/home/lin/local/ioapi-3.0/ioapi/bufint3.c:(.text+0x142b): additional relocation overflows omitted from the output
make: *** [Bcon_hr_cb4_cntl.exe] Error 1
3.Solution
Applications containing more than 2 GB of static data should be built with
"-mcmodel medium -shared-intel" options.
In my application an huge array as following to hold all data needs is used.
---------------------------------------------------------------------------
INTEGER, PARAMETER :: MAXNI = 360, #longtitude
& MAXNJ = 180, #latitude
& MAXNP = 50, #height
& MAXNT = 24, #hours
& MAXNV = 10, #variables
REAL :: meadia(MAXNI,MAXNJ,MAXNP,MAXNT, MAXNV) ! org conc
----------------------------------------------------------------------------
The static array will be:
360×180×50×24×10×4(4bytes/real data type) = 3110,400,000bytes about 3.1G
After specified "-mcmodel medium -shared-intel" the compiler options, the error disappeared.
NOTE:
1)It seems that this error only occurs on AMD 64 CPU architecture. I successed compiling the same application on IA 64 CPU without getting an error.
2)The same error occurred even if specified the "-mcmodel medium -shared-intel" options. Check your sizes of all your static arrays again to make sure they are not too huge.
Theoretically you can not use a static array more than 4G in AMD/IA 32 CPU,
16G in AMD/IA 64 CPU.
4.Reference
http://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/54173
-
Sunday, September 21, 2008
Print to pdf in command line
1)Download the cups-pdf Package
search for the cups-pdf package for your version of openSUSE.
Next to the first result, click "1-Click Install" and follow the steps to install the cups-pdf package.
2)Set cups-pdf File Permission
Since version 1.2, cups don't support option "RunAsOption" anymore but cups-pdf needs root privileges in order to modify file ownerships.
sudo chmod +s /usr/lib/cups/backend/cups-pdf
3)Install the Printer
(1).Open the CUPS Administration page using a web browser like Firefox (visit http://localhost:631/admin, note: the CUPS service must be running, see System Services (runlevel).)
(2). Select the Administration tab and click Find New Printers
(3). You should see Virtual PDF Printer (CUPS-PDF), click Add This Printer
(4). Click Continue
(5). In the next screen MAKE/MANUFACTURER FOR CUPS-PDF, don't select a printer but in the OR Provide a PPD File section, provide the name of the driver by browsing to /usr/share/cups/model/CUPS-PDF.ppd then click Add Printer.
(6). Use the "root" username and password (or any username with CUPS admin rights) when prompted finish adding the new printer.
4)Configuration Options
PDF Output Location, the default location for the PDF files is
/var/spool/cups-pdf/yourusername/
To change this, edit the /etc/cups/cups-pdf.conf file.
In this case, to the Desktop of the user.
Out ${HOME}/Desktop
2.Print pdf from command line ( Shell file )
#!/bin/csh
set printer=cups-pdf
if( $1 != "" ) then
lpr -P$printer $1
echo ${1} sent to $printer ... OK!
else
echo PDF Print: No filename defined!
endif
save shell script above to pdfprint.bash and make it executable by
chmod +x pdfprint.bash
use pdfprint.bash filename to print.PDF files are output to you desktop.
3.Supplement
At first I meant to use kprinter to print to file(PDF) function.
You can use kprinter at command line.
example:
kprinter --nodialog -d printername filename
more help can be found by using:
kprinter --help
But I can't find the right printername for "print to file (PDF)" option in the kprinter dialog . :-(
It is said that the printer name is the name that appears in the print dialog. If you want to print to PDF, then it's "Print to File (PDF)", there's no easy shortcut.
But it still doesn't work. The error message says that "not found specified or default printer".
-