Friday, 11 September 2009
Subversion hangs on commit
If you find that your subversion commands such as commit are hanging before they complete (usually requiring a kill -9 to exit from) and you are using Apache as the webserver, make sure that the Apache KeepAlive directive is on.
Thursday, 28 May 2009
.infig.status: error: cannot find input file
Seen when running ./configure before building an application from sourcecode.
Cause: Seems to be caused (under Linux) by having DOS style line endings in the configure script.
Solution: Open 'configure' in a Linux text editor (like kwrite), small change, undo the change and save the file so that it writes in all the correct line endings.
Alternative is to use tr to do the conversion:
tr -d "\15\32" < configure > configure.new
./configure.new
Cause: Seems to be caused (under Linux) by having DOS style line endings in the configure script.
Solution: Open 'configure' in a Linux text editor (like kwrite), small change, undo the change and save the file so that it writes in all the correct line endings.
Alternative is to use tr to do the conversion:
tr -d "\15\32" < configure > configure.new
./configure.new
Monday, 26 January 2009
Setting monitor powersaving on eeepc
To prevent the eeepc going to sleep when shutting the lid.
Open a terminal (ctrl-alt-t)
Login as root (su)
edit the file (using pico or some other editor) /etc/acpi/lidbtn.sh
comment out (with a #) the line
/etc/acpi/suspend2ram.sh
Save the file.
eeepc should now remain awake when lid is shut.
To prevent external monitor going to sleep after timeout
xset -dpms
This deactivates Energy Star
Open a terminal (ctrl-alt-t)
Login as root (su)
edit the file (using pico or some other editor) /etc/acpi/lidbtn.sh
comment out (with a #) the line
/etc/acpi/suspend2ram.sh
Save the file.
eeepc should now remain awake when lid is shut.
To prevent external monitor going to sleep after timeout
xset -dpms
This deactivates Energy Star
Wednesday, 17 December 2008
Cannot restore segment prot after reloc: Permiss
Occured when attempting to load the libphp5.so module into Apache using RedHat linux.
Fixed by running:
system-config-securitylevel
and setting SELinux to Permissive
Fixed by running:
system-config-securitylevel
and setting SELinux to Permissive
Tuesday, 9 December 2008
Creating flash video (flv) files with ffmpeg
First, install Lame., to access the mp3 codec.
Second, install ffmpeg. Ensuring that you run the configure script with the --enable-libmp3lame option.
(I used ./configure --disable-vhook --enable-x11grab --enable-gpl --disable-bzlib --enable-libx264 --enable-libmp3lame).
Thirdly, use ffmpeg thus:
ffmpeg -i myinputfile.mpeg -ar 22050 -ab 56000 -b 200000 -acodec libmp3lame -ac 1 myoutputfile.flv
Second, install ffmpeg. Ensuring that you run the configure script with the --enable-libmp3lame option.
(I used ./configure --disable-vhook --enable-x11grab --enable-gpl --disable-bzlib --enable-libx264 --enable-libmp3lame).
Thirdly, use ffmpeg thus:
ffmpeg -i myinputfile.mpeg -ar 22050 -ab 56000 -b 200000 -acodec libmp3lame -ac 1 myoutputfile.flv
Friday, 5 December 2008
Flash files won't work in any old directory?
Flash player 9 (and presumably all subsequent releases) have security features that limit where data and files can be accessed from.
Check the following directory (under windows):
c:\Documents and Settings\\Application Data\Macromedia\Flash Player\#Security\FlashPlayerTrust
Within will be some .cfg files, each specifying permitted directories for playing Flash (SWF) files.
Feel free to add your own,
i.e. file: mydir.cfg
contents: C:\temp
Will allow you to play swf files in your c:\temp directory
Check the following directory (under windows):
c:\Documents and Settings\
Within will be some .cfg files, each specifying permitted directories for playing Flash (SWF) files.
Feel free to add your own,
i.e. file: mydir.cfg
contents: C:\temp
Will allow you to play swf files in your c:\temp directory
Tuesday, 28 October 2008
Calculating field of view from focal length
From wikipedia article.
a = 2 atan (d/2f)
where:
a = angle of view,
d = sensor size in direction that angle is required,
f = focal length
a = 2 atan (d/2f)
where:
a = angle of view,
d = sensor size in direction that angle is required,
f = focal length
Friday, 10 October 2008
How to check the architecture for which a Linux app is compiled.
readelf -a
Will give all the details of the compiled code.
Will give all the details of the compiled code.
Tuesday, 23 September 2008
Storing a procedure in mySQL
Simple alias for a more complex command...
create procedure nameofmyprocedure () select * from mytable;
To use within mySQL
call nameofmyprocedure();
This assumes that no arguments are required (empty argument list () ).
create procedure nameofmyprocedure () select * from mytable;
To use within mySQL
call nameofmyprocedure();
This assumes that no arguments are required (empty argument list () ).
Fixing undefined reference to vtable errors in QT3
Assuming that you have added the Q_OBJECT macro to your class definition then the problem is that you are not generating and referencing the moc file for that class.
Easiest way to fix is to run qmake on your src.pro file (if you are using kdevelop, making sure that qmake is the correct one for your version, QT3 and QT4 qmake are not the same.)
Alternatively, run
moc -o myheader.moc myheader.h
and include the myheader.moc file in your project. It will need to be updated every time you change your SIGNALS or SLOTS in that class, so you may want to automate its creation.
Easiest way to fix is to run qmake on your src.pro file (if you are using kdevelop, making sure that qmake is the correct one for your version, QT3 and QT4 qmake are not the same.)
Alternatively, run
moc -o myheader.moc myheader.h
and include the myheader.moc file in your project. It will need to be updated every time you change your SIGNALS or SLOTS in that class, so you may want to automate its creation.
Friday, 12 September 2008
Linux library types
Copied from yolinux.
.a Static library, the contents become part of the compiled executable.
.so Dynamically linked shared object library. Do not become part of the executable but must be present at run-time.
How to generate a static library (.a)
Compile: cc -Wall -c ctest1.c ctest2.c
Compiler options:
-Wall: include warnings. See man page for warnings specified.
Create library "libctest.a": ar -cvq libctest.a ctest1.o ctest2.o
List files in library: ar -t libctest.a
Linking with the library:
cc -o executable-name prog.c libctest.a
cc -o executable-name prog.c -L/path/to/library-directory -lctest
How to generate a dynamically linked shared object library: .so
Create object code
gcc -Wall -fPIC -c *.c
Create library
gcc -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0 *.o
Optional: create default version using symbolic link
mv libctest.so.1.0 /usr/lib
ln -sf /usr/lib/libctest.so.1.0 /usr/lib/libctest.so
ln -sf /usr/lib/libctest.so.1.0 /usr/lib/libctest.so.1
Compiler options:
-Wall: include warnings. See man page for warnings specified.
-fPIC: Compiler directive to output position independent code, a characteristic required by shared libraries. Also see "-fpic".
-shared: Produce a shared object which can then be linked with other objects to form an executable.
-W1: Pass options to linker.
In this example the options to be passed on to the linker are: "-soname libctest.so.1". The name passed with the "-o" option is passed to gcc.
Option -o: Output of operation. In this case the name of the shared object to be output will be "libctest.so.1.0"
Library Links:
The link to /usr/lib/libctest.so allows the naming convention for the compile flag -lctest to work.
The link to /usr/lib/libctest.so.1 allows the run time binding to work. See dependency below.
Compiling for runtime linking with a dynamically linked libctest.so.1.0:
gcc -Wall -I/path/to/include-files -L/path/to/libraries prog.c -lctest -o prog
Use:
gcc -Wall -L/opt/lib prog.c -lctest -o prog
Where the name of the library is libctest.so. (This is why you must create the symbolic links or you will get the error "/usr/bin/ld: cannot find -lctest".)
The libraries will NOT be included in the executable but will be dynamically linked during runtime execution.
The shared library dependencies of the executable can be listed with the command: ldd name-of-executable
.a Static library, the contents become part of the compiled executable.
.so Dynamically linked shared object library. Do not become part of the executable but must be present at run-time.
How to generate a static library (.a)
Compile: cc -Wall -c ctest1.c ctest2.c
Compiler options:
-Wall: include warnings. See man page for warnings specified.
Create library "libctest.a": ar -cvq libctest.a ctest1.o ctest2.o
List files in library: ar -t libctest.a
Linking with the library:
cc -o executable-name prog.c libctest.a
cc -o executable-name prog.c -L/path/to/library-directory -lctest
How to generate a dynamically linked shared object library: .so
Create object code
gcc -Wall -fPIC -c *.c
Create library
gcc -shared -Wl,-soname,libctest.so.1 -o libctest.so.1.0 *.o
Optional: create default version using symbolic link
mv libctest.so.1.0 /usr/lib
ln -sf /usr/lib/libctest.so.1.0 /usr/lib/libctest.so
ln -sf /usr/lib/libctest.so.1.0 /usr/lib/libctest.so.1
Compiler options:
-Wall: include warnings. See man page for warnings specified.
-fPIC: Compiler directive to output position independent code, a characteristic required by shared libraries. Also see "-fpic".
-shared: Produce a shared object which can then be linked with other objects to form an executable.
-W1: Pass options to linker.
In this example the options to be passed on to the linker are: "-soname libctest.so.1". The name passed with the "-o" option is passed to gcc.
Option -o: Output of operation. In this case the name of the shared object to be output will be "libctest.so.1.0"
Library Links:
The link to /usr/lib/libctest.so allows the naming convention for the compile flag -lctest to work.
The link to /usr/lib/libctest.so.1 allows the run time binding to work. See dependency below.
Compiling for runtime linking with a dynamically linked libctest.so.1.0:
gcc -Wall -I/path/to/include-files -L/path/to/libraries prog.c -lctest -o prog
Use:
gcc -Wall -L/opt/lib prog.c -lctest -o prog
Where the name of the library is libctest.so. (This is why you must create the symbolic links or you will get the error "/usr/bin/ld: cannot find -lctest".)
The libraries will NOT be included in the executable but will be dynamically linked during runtime execution.
The shared library dependencies of the executable can be listed with the command: ldd name-of-executable
Monday, 8 September 2008
Automating FTP transfer with linux
edit file ~/.netrc to contain
machine sample.ftpsite.com
login anonymous (or user name)
password mymail@mydomain.com (or user's password)
Make sure you:
chmod 600 ~/.netrc
To keep your passwords secure.
The ftp client will check the contents of this file when performing an ftp connection and will use the login and password when the machine matches one of the entries in the file. This is useful when writing a script to automate file transfer (as part of a cronjob for example) as no user intervention is necessary.
machine sample.ftpsite.com
login anonymous (or user name)
password mymail@mydomain.com (or user's password)
Make sure you:
chmod 600 ~/.netrc
To keep your passwords secure.
The ftp client will check the contents of this file when performing an ftp connection and will use the login and password when the machine matches one of the entries in the file. This is useful when writing a script to automate file transfer (as part of a cronjob for example) as no user intervention is necessary.
The FTP script itself might look like:
open sample.ftpsite.com
cd backupdir
lcd mylocalbackups
put backupfile.log
That script (remember to chmod +x scriptname) can be added to the cron daemon.
Friday, 29 August 2008
Linux: Check if a system service is running...
As root:
chkconfig [name of service]
i.e.
chkconfig sendmail
chkconfig [name of service]
i.e.
chkconfig sendmail
Wednesday, 20 August 2008
Backing up MySQL databases
Backup...
> mysqldump mydatabase > mydatabase.sql
Restore...
> mysql < mydatabase.sql
Options:
-X : outputs database info as XML.
--all-databases : dumps all databases to stdio
-p : to add a password
> mysqldump mydatabase > mydatabase.sql
Restore...
> mysql < mydatabase.sql
Options:
-X : outputs database info as XML.
--all-databases : dumps all databases to stdio
-p : to add a password
Monday, 18 August 2008
Finding Linux xwindow size
xwininfo -stats -root
will return info including the width and height of your screen.
will return info including the width and height of your screen.
Capturing the screen to video with ffmpeg
Using ffmpeg...
ffmpeg -f x11grab -s 1280x1024 -r 25 -i :0.0 /tmp/out.mpg
Assumes that --enable-x11grab switch was used during configuration.
ffmpeg -f x11grab -s 1280x1024 -r 25 -i :0.0 /tmp/out.mpg
Assumes that --enable-x11grab switch was used during configuration.
Adding H264 to ffmpeg and libraries
In the configuration command add --enable-libx264
In any code using libavcodec, link to /usr/lib64/libx264
In any code using libavcodec, link to /usr/lib64/libx264
Friday, 1 August 2008
Using subversion through a proxy
Linux:
In the file ~/.subversion/servers
under the [global] section, uncomment the http-proxy-host entry and make sure it points to your proxy server address.
http-proxy-host = myproxy.address.com
Check that the port is correct as well.
In the file ~/.subversion/servers
under the [global] section, uncomment the http-proxy-host entry and make sure it points to your proxy server address.
http-proxy-host = myproxy.address.com
Check that the port is correct as well.
Thursday, 31 July 2008
To create a continuous pipe to stream a real-time video
At the server:
> mkfifo fifo.flv
> APPTOMAKEFLVFILE fifo.flv &
> netcat -l -p 1234 < fifo.flv
At the client
> netcat SERVERADDRESS 1234 | ffplay pipe:
In this case, the APPTOMAKEFLVFILE is compiled from the output_example.c file that comes with the ffmpeg download from http://ffmpeg.mplayerhq.hu/
> mkfifo fifo.flv
> APPTOMAKEFLVFILE fifo.flv &
> netcat -l -p 1234 < fifo.flv
At the client
> netcat SERVERADDRESS 1234 | ffplay pipe:
In this case, the APPTOMAKEFLVFILE is compiled from the output_example.c file that comes with the ffmpeg download from http://ffmpeg.mplayerhq.hu/
Subscribe to:
Posts (Atom)