LinuxSoftware

Coding and tramping in Aotearoa / New Zealand

Q. I wanted to open a file once, but read its contents many times. But at the end of the first read the read pointer was at EOF so the subsequent reads contained nothing. Do you know how to rewind the file so that you can read from the start?
A. Use seekg, probably need to clear the eof flag too. Probably better just to reopen the stream. (See also c++ and http://www.cppreference.com/cppio_details.html.)


Q. Could you point me to some recommended tutorials about setting up a webserver and PHP?
A. Yep, sure. See PHP.


Q. Why are Word attachments a bad idea?
A. See http://www.fsf.org/philosophy/no-word-attachments.html and http://www.kurahaupo.gen.nz/~martin/public_data_formats.html


Q. If you need big MySQL queries (for example, if you are working with big BLOB columns), you can increase the query limit by starting mysqld with the -O max_allowed_packet=# option (default 1M). The extra memory is allocated on demand, so mysqld will allocate more memory only when you issue a big query or when mysqld must return a big result row!

It works for exactly 1M, so how do add the -0.... parameter to the mysqld start up??
A. Set it in /etc/my.cnf

e.g.

[mysqld]
port=3306
socket=/tmp/mysql.sock
set-variable = key_buffer_size=16M
set-variable = max_allowed_packet=1M

http://www.mysql.com/doc/en/Option_files.html*


Q. 1) Any alternative text-to-speech progs that produce decent quality speech?, or 2) Any better voices for Festival I can find?
A. Have a look at ...
http://www.speech.cs.cmu.edu/hephaestus.html
http://freetts.sourceforge.net - Java


Q. Do you know of any decent C/C++ IDE for Linux?
A. Vim is my choice. Others like Emacs. There's also Anjuta, KDevelop, Source-Navigator and Eclipse. If you're after a RAD GUI builder try Kylix. DDD and GVD are good GUI front-ends for GDB.


Q. What is the command to rename a bunch of files to a different extension? I tried "mv *.MP3  *.mp3" but this said that the second part had to be a directory?
A. The command is "rename". You should have it installed already, RedHat 9 has it in util-linux-2.11y-9.i386.rpm.

  • e.g. rename MP3 mp3 *


Q. I need to get the output of ls -lR on the remote ftp server, and store it for parsing (I am searching for a file somewhere in a big dir tree)?
A. Try ncftpls, e.g. ncftpls -R ftp://ftp.auckland.ac.nz. On RH9 this is part of ncftp-3.1.5-4.i386.rpm.


Q. Hey, I upgraded my Linux install and I lost my modem?
A. Bottom line is modules are really only binary compatable with a certain version of the Linux kernel... which is why they are much better distributed as source.


Q. How to set up a Linux based stand alone mail server? What standard Linux components would you use?
A. Short answer: Fetchmail, Postfix and Spam Assassin/Spam Bayes. see LinuxMailServer.


Q. How do you change the hostname of a RedHat Linux box??
A. Run redhat-config-network (aka neat) and change Hostname on the DNS tab. This will update /etc/sysconfig/network (and maybe some other places).
Optionally add this name to the entry in your /etc/hosts file. eg: change the line that says

127.0.0.1 localhost.localdomain  localhost old.domain.name

to

127.0.0.1  localhost.localdomain localhost new.domain.name

After changing that stuff, restart the networking subsystem, and see how it goes. (service network restart)


Q. Is there is a similar mechanism for the NIS domain name.?
A. Try looking at authconfig-gtk.


Q. Where can I get a copy of Linux?
A. See http://www.linuxshop.co.nz http://www.linuxcdmall.co.nz http://www.xsolutions.co.nz http://www.linux.net.nz/node/view/13


Q. How do I iterate over keys and values from a Python dict?
A. for key, value in mydict.iteritems()


Q. How do you write scripts to automate mysql table creation deletion etc?
A. mysql will read commands from stdin, so.. mysql -umynanme -pmypasswd < myscript.sql


Q. Is there a utility that will allow me to listen to and modify wave files.?
A. Have a read of The Linux Soundfile Editor Roundup


Q. you mentioned some service that I may need to turn back on to get my machine running faster on the network, any idea of what it's called??
A. For faster name lookups try nscd - the name service cache daemon. I have it disabled because I want the most uptodate DNS entries, but if your DNS server is very slow nscd may help.