Tuesday 9 February 2010

2d dynamic array to be passed in a C function

To allocate it:

float **out=(float **)malloc(nRows * sizeof(float *));
for(unsigned int i = 0; i < nRows; i++)
out[i]=(float *)malloc(nCols * sizeof(float));

To free it:

for(unsigned int i = 0; i < nRows; i++)
free(out[i]);
free(out);

Monday 8 February 2010

From http://www.physicsforums.com/showpost.php?p=1948692&postcount=4

Re: Passing a 2d array to a function in C

#include
#include
#include
// Ref : http://www.eskimo.com/~scs/cclass/int/sx9b.html
void printArray(int **array, int m, int n)
{
for(int i=0;i}
int main()
{
int i,j,k=0, m=5, n=20;
int **a=(int **)malloc(m*sizeof(int *));
for(i=0;i for(i=0;i //for(i=0;i printArray(a,m,n);
system("PAUSE");
return 0;
}

Thursday 19 November 2009

Convert "windows flv" to "linux mp4"

ffmpeg -i name.flv -acodec copy -vcodec copy name.mp4

Friday 25 September 2009

convert set of images to video

To convert a set of images into an mpg video use:

ffmpeg -f image2 -i test-%10d.jpg out.mpg

Wednesday 8 July 2009

install ms office 2007 on ubuntu 8.04

the following guide did the job ok for 8.04 as well
http://samanathon.com/how-to-install-microsoft-office-2007-in-ubuntu-9-04/

1) basically use wine 1.1.14
2) run setup and install office
once finished
3) install cabextract (apt-get)
4) download winetricks and run
sh winetricks corefonts tahoma vcrun2005sp1 wsh56js
5) configure wine (winecfg), go to libraries and add riched20 and set this one to native. also add usp10 (as it is).

Wednesday 17 June 2009

make wifi light indicator of acer 5920g work under ubuntu 8.04 hardy heron

Install the linux-restricted modules and it should be OK.

make multimedia keys and scroll buttons of an acer 5920g work in ubuntu 8.04 hardy heron

Roughly,
backup your xorg.conf
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.original

edit the xorg.conf
sudo gedit /etc/X11/xorg.conf

to the following

# xorg.conf (X.Org X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the xorg.conf manual page.
# (Type "man xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
# sudo dpkg-reconfigure -phigh xserver-xorg

Section "InputDevice"
Identifier "Generic Keyboard"
Driver "kbd"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
# Option "CorePointer"
Option "SendCoreEvents" "true"
EndSection

#Section "InputDevice"
# Identifier "Synaptics Touchpad"
# Driver "synaptics"
# Option "SendCoreEvents" "true"
# Option "Device" "/dev/psaux"
# Option "Protocol" "auto-dev"
# Option "HorizEdgeScroll" "0"
#EndSection

Section "InputDevice"
Identifier "TouchPad"
Driver "synaptics"
Option "CorePointer"
Option "Protocol" "event"
Option "Device" "/dev/input/eventtouchpad"
Option "MaxTapTime" "100"
Option "MaxTapMove" "220"
Option "AccelFactor" "0.05"
Option "SHMConfig" "true"
EndSection

Section "InputDevice"
Identifier "AcerMediaKeys"
Driver "evdev"
Option "Device" "/dev/input/eventkeys"
Option "SendCoreEvents" "true"
EndSection

Section "Device"
Identifier "Configured Video Device"
Driver "nvidia"
Option "NoLogo" "True"
EndSection

Section "Monitor"
Identifier "Configured Monitor"
EndSection

Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
Defaultdepth 24
EndSection

Section "ServerLayout"
Identifier "Default Layout"
screen "Default Screen"
# Inputdevice "Synaptics Touchpad"
Inputdevice "TouchPad"
Inputdevice "AcerMediaKeys"
Inputdevice "Configured Mouse"
EndSection

Section "Module"
Load "glx"
EndSection
###########################################


Now do the following:
sudo gedit /etc/udev/rules.d/10-acersynaptics.rules

and paste the following:
SUBSYSTEMS=="input", ATTRS{phys}=="isa0060/serio4/input0", KERNEL=="event*", NAME="input/eventtouchpad"
SUBSYSTEMS=="input", ATTRS{phys}=="isa0060/serio3/input0", KERNEL=="event*", NAME="input/eventkeys"


Save and exit. I think this should be enough for the scroll buttons.

For the multimedia keys now to work.
Install xbindkeys
sudo apt-get install xbindkeys

Make them run at startup. The simplest is go to System->Preferences->Session

On your home directory
gedit ~/.xbindkeysrc

and paste the following (this is for exaile).
"exaile -t"
b:17

"exaile -s"
b:18

"exaile -p"
b:19

"exaile -n"
b:20


Restart and it should now be working.
I think that's all. There is also a post in the ubuntuforums from which I got the info.