Solutions to technical problems that I come across. Keywords: The Web, Ubuntu, Windows, JavaScript, jQuery, AngularJS, PHP, Java, C++, mySQL, noSQL, and more.
Thursday, April 30, 2009
Posting code in blogger
A good site that converts special characters in text to postable code is Postable.
Source: http://scrapur.com/index/displaying-html-code-in-between-blog-post/
Meta tags in blogger
"/>
' not just '">
'.So go to the Layout tab, select edit html, find your
<title>
tag, right beneath it enter for example:<meta name="description" content="Solutions to technical problems that I come across. Usually for general use of Ubuntu and writing code for the NVIDIA CUDA architecture."/>
Solution source: http://www.sitepoint.com/forums/showthread.php?t=517353
Tuesday, April 28, 2009
cron popularity-contest
Ever wonder what the script popularity-contest
that can be found in /etc/cron.weekly/
is?
Well it is a script that periodically anonymously sends applications use statistics to Ubuntu so that they can decide what programs are most useful and should be included on the Ubuntu CD or be automatically installed.
It is not enabled by default, but if you want to help out; go to System->Administration->Software Sources
and select the statistics
tab, here you can check or uncheck for submitting statistical information.
Slow Ubuntu startup because of tracker and updatedb
The applications tracker
and updatedb
(which is used for locate
) seem to run at startup every day on some machines. This causes the machine to be much slower until they have finished, which is annoying.
Disabling Tracker
You can disable tracker if you don't use it. Open a console window and navigate to /etc/xdg/autostart/
and edit the file trackerd.desktop
as root (using sudo). Add the line
Hidden=true
to the end of the file. do the same with the file tracker-applet.desktop
.
This will disable the tracker for all users on the machine. To disable the tracker for a specific user only follow the guide on https://wiki.ubuntu.com/Tracker, which is where I found this solution too.
Cleaning up updatedb
updatedb
is used to keep track of all files one your harddrive so that you can search them using locate
. However there are on some machines installed several scripts that will run this program every time it boots and thus slow it down. Having this database updated every day seems like overkill to me, weekly should be sufficient.
Open a console window and navigate to /etc/cron.daily/
, list the files there. If you find the files find.notslocate or find.notslocate.dpkg-new remove them using
sudo rm find.notslocate
sudo rm find.notslocate.dpkg-new
Check to see if you have both mlocate
and slocate
files you only need one of them. mlocate
is the prefered locate by Ubuntu so lets remove slocate
. Type:
sudo apt-get purge slocate
to remove it. It might say that slocate
is already uninstalled, in that case remove the slocate script by typing
sudo rm slocate
Finally lets move all the scripts that run updatedb
to cron.weekly
(which make them run weekly instead of daily). From the cron.daily folder type:
sudo mv mlocate ../cron.weekly/.
sudo mv find ../cron.weekly/.
To learn more about mlocate versus slocate check out http://shallowsky.com/blog/tags/boot/, which is where I found the solution to this problem.
Monday, April 27, 2009
Dropbox
In Ubuntu simply type
sudo aptitude install nautilus-dropbox
to install. Sign up through the application and voila 2GB available from everywhere.
Cleaning up Ubuntu
The following have easy to follow instructions:
http://ubuntuforums.org/showthread.php?t=140920
http://benhodge.wordpress.com/2008/02/17/cleaning-up-a-ubuntu-gnulinux-system/
I haven't tried to remove orphaned packages because I read that this could mess up your system, so use at your own risk.
Also try
xdiskusage
, its available through aptitude and gives you a good overview over what folders take up the most space.
Setting up a CUDA environment in Ubuntu Jaunty
Install the build tools we need
Open a console window and type the following:
sudo apt-get install build-essential libglut3-dev
Install the NVIDIA drivers
Go to the CUDA ZONE download page and download the CUDA driver. (The Ubuntu 8.04 will work for Ubuntu 9.04 Jaunty).
Press CTRL+ALT+F1 to go to a terminal, log in with your username and password.
Navigate to the folder that you placed the driver file in and type the following:
chmod +x NVIDIA-Linux-x86_64-180.22-pkg2.run
This will first make the driver installer runnable. We then need to stop Xwindows (remember to save any open files). (if you are using KDE use kdm instead of gdm (which is for gnome)):
sudo /etc/init.d/gdm stop
Next we run the driver installation (Usually selecting yes to all questions is ok):
sudo ./NVIDIA-Linux-x86_64-180.22-pkg2.run
Finally we restart the Xwindows session.
sudo /etc/init.d/gdm start
A new error for Ubuntu Jaunty is that upon reboot you might get a message similar to:
(EE)Failed to load module "type1" (module does not exist,0)
(EE)Failed to load module "freetype" (module does not exist,0)
(EE) NVIDIA(0) Failed to load the NVIDIA Kernel Module
(EE) NVIDIA ***Aborting***
(EE) Screen(s) found, but none have a usable configuration.
To fix this problem edit the file
/etc/modprobe.d/lrm-video
and comment out the line install nvidia /sbin/lrm-video nvidia $CMDLINE_OPTS
by putting a # in front of it.Solution found from: http://ubuntuforums.org/showthread.php?t=950777
Install the CUDA Toolkit
Go to the CUDA ZONE download page again and download the CUDA Toolkit. Open a console window and navigate to the directory containing the file, type the following:
chmod +x cudatoolkit_2.1_linux64_rhel5.2.run
sudo ./cudatoolkit_2.1_linux64_rhel5.2.run
Use the default options suggested by the installer (press enter).
Note: The following steps need to be taken by all users
Add environment variables
This is very important step.
Open a console window to your home directory and edit the file
.bashrc
, this is the settings file for your console window. Add the following lines to the bottom of the file:PATH=$PATH:/usr/local/cuda/bin
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib
export PATH
export LD_LIBRARY_PATH
These settings will not take effect before you open a new window so remember to do that.
Install the CUDA SDK
download the CUDA SDK from the CUDA ZONE download page. As with the Toolkit, open a console window, navigate to the directory with the files and type the following:
chmod +x cuda-sdk-linux-2.10.1215.2015-3233425.run
./cuda-sdk-linux-2.10.1215.2015-3233425.run
Accept the default options. The installer will create a folder called NVIDIA_CUDA_SDK in your home directory.
Compile and run an example
Open a console window, navigate to the NVIDIA_CUDA_SDK folder in your home directory, type:
make
./bin/linux/release/fluidsGL
This should open a window with a fluid dynamics simulation.
Writing code for CUDA devices
When writing code for CUDA GPUs its is useful to begin from the examples included in the SDK, the source code can be found in
~/NVIDIA_CUDA_SDK/projects/
(the directory in your home directory). Copy one of the directories and start editing the files in it. To compile the program type make
.If you want to put the files in a different directory or rename or add files to your project, you need to edit the
Makefile
file in your project directory and possibly also the common.mk
file located in ~/NVIDIA_CUDA_SDK/common/
folder.
Dosbox and Ubuntu 9.04 Jaunty
I've been having problems with my DOSBox after upgrading to Jaunty. Here's problems and the fix for one of them at least:
1. The arrow keys are not responding. (actually they are mapped to totally different keys)
For Ubuntu Jaunty the 'usescancodes' option for SDL must be disabled. To do this you edit the DOSBox config file (dosbox.conf or .dosboxrc), go to the [sdl] section and edit the line to say:
usescancodes=false
This should do the trick.
The following sites are where I found the solution:
http://ubuntuforums.org/showthread.php?p=5963381
http://vogons.zetafleet.com/viewtopic.php?t=19851
If you haven't got a dosbox.conf or .dosboxrc file in your home directory you can create it by doing the following:
- Open DOSBox
- Type 'config -writeconf dosbox.conf'
- The file dosbox.conf will be created in your home directory
- Rename the file to .dosboxrc if you want it to be hidden
2. The sound is either totally gone or stuttering.
UPDATE: Use export SDL_AUDIODRIVER=esd
instead, you will also need to have the package libsdl1.2debian-esd
installed. See comments, thanks to mgedmin
and Alex
for the solution.
I haven't found the solution to this problem yet, noone seems to have (So if you have please tell me). But one can try the following: The problem is apparently caused by the change from ALSA sound server to PulseAudio.
Download the PulseAudio plugin, libsdl1.2debian-pulseaudio using synaptic or by typing:
sudo aptitude install libsdl1.2debian-pulseaudio
You will be asked to uninstall libsdl1.2debian-alsa. alternatively you can install libsdl1.2debian-all if you want to keep the ALSA plugin.
Now you need to tell SDL (which is what DOSBox is built on) to use PulseAudio, type export SDL_AUDIODRIVER=pulse
in a console window, then start dosbox from the same window by typing dosbox
.
You might also be getting errors like
ALSA:Can't subscribe to MIDI port (65:0) nor (17:0)
MIDI:Opened device:oss
then go to the dosbox.conf file, find the MIDI section and change the settings in there to:
mpu401=intelligent
device=default
config=128:0
Hope some of this is of any help to you.