Tuesday, 6 July 2010

OBJ model fails to load in Away3D

Error contains:
Error #1009: Cannot access a property or method of a null object reference
away3d.loaders::Obj/parseMtl()...


Seems to affect OBJ files that contain mtl file references that have been created on a Linux PC.

Solution is to open the obj file in wordpad in Windows and just resave it.
I suspect that this changes the line endings to Windows native format.

Thursday, 22 April 2010

using printf in libavcodec

Although av_log is preferred, you can use printf statements for your own personal debugging processes by adding

#undef printf

before any of your own code.

Thursday, 11 March 2010

Actionscript 3: Error: Call to possibly undefined method addEventListener through a reference with a static type class

If you have been following Gustavo Kawamoto's instructions for making a Actionscript 3 static, singleton class you might be have received the undefined method addEventListener error when trying to set up an event listener for your static object.

The thing to remember is that you must add an event listener on an object instance, so try the following:

MyStaticClass.getInstance().addEventListener(MyEvent.BLAH, myHandler);


This works since the getInstance() method returns the instance of your static singleton.

Tuesday, 5 January 2010

Firefox slow in Ubuntu. DNS lookup fix.

Problem: Firefox takes an age to resolve host addresses in Ubuntu.

Solution:
Open Firefox,
type about:config into the address bar, press return,
Scroll down to the entry network.dns.disableIPv6 and set it to TRUE (with a right mouse click).
Surf away.


With thanks to http://www.craigmayhew.com/blog/2009/11/slow-dns-lookups-in-firefox-on-ubuntu-9-10-karmic-koala/

Wednesday, 25 November 2009

/usr/include/qt4/QtCore/qtconcurrentfilter.h:227: error: expected nested-name-specifier before numeric constant and other errors compiling Qt4

If you see a load of compile errors from Qt4 classes when doing a compile, this is sometimes caused by your #include statements.
To fix it, replace all the #include <qwhatever>with a single

#include <QtGui>

instead. (For GUI elements anyway. See /usr/include/qt4/Qt directory for other default includes like QtNetwork etc etc)
You should be using that anyway, but QT3 habits die hard.

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

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

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

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

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

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

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.

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 () ).

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.

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

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.


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.

Pipe into gzip

cat myfile.txt | gzip -f > myfile.txt.gz

Friday, 29 August 2008

Linux: Check if a system service is running...

As root:

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