Posts tagged ‘ubuntu’
It used to be a real pain to try and get google calendar working with kontact/korganiser, however now it is very simple. I have also provided a screenshot walk-through to aide the process.
Just install akonadi-kde-resource-googledata using your package manager or in the terminal with:
sudo apt-get install akonadi-kde-resource-googledata
This will install support of google calendar and google contacts into akonadi. If you’ve not heard of akonadi before, it is a backend that manages communications and protocols. So rather than having developers of separate applications working on the same thing rewriting code that does the same thing they can simply plug into akonadi. Kontact/korganiser can load can load from an akonadi resource:
Walkthrough
(see below for walkthough with screenshots)
- Right Click on calendars and click add resource
- Select akonadi
- Click Manage Calendar Sources
- Click add
- Select Akonadi Google Calendar Resource
- Enter your email and password and select ok
- Your calendar should now sync and appear in korganiser
Screenshot Walkthrough
I like using samba as a password-less method for people on a network to share and access files on my computer. This works well on a network you trust like a small home network or a small private network, however on different networks restricted access is preferred.
For me this problem is solved by simply having a button to turn samba on and off. This will also have the side effect that you will not be able to access anyone else’s shares but is sufficient for my needs.
Bash script
#!/bin/bash smb=`sudo /etc/init.d/samba status | grep running | wc -l` if [ $smb -gt 0 ] then # Stop samba sudo /etc/init.d/samba stop else # Start samba sudo /etc/init.d/samba restart fi
Where username is replaced with your username.
The script simply checks the status of samba to see if it is running, if it is then it is killed otherwise it is started. kdialog is used to display a notification of which toggle state we are in.
Adding a notification (KDE)
#!/bin/bash smb=`sudo /etc/init.d/samba status | grep running | wc -l` if [ $smb -gt 0 ] then # Stop samba sudo /etc/init.d/samba stop sudo -u username kdialog --passivepopup 'Samba off' 3 else # Start samba sudo /etc/init.d/samba restart sudo -u username kdialog --passivepopup 'Samba on' 3 fi
We run kdialog through `sudo -u username` because when the script is run with sudo the current user will be root, and using this will cause kdialog to display an ugly notification.
For an example of this try running `sudo kdialog “ugly message” 3`
As opposed to `sudo -u username kdialog –passivepopup ‘lovly message’ 3`
Creating an icon/button (KDE)
You can then turn this into a button you can simply click my creating a desktop file. In KDE Right click > new > link to application. Then fill in the application tab with the information as in the following image:
In the General tab you can give the button a name and choose the icon of your choice, click OK, and now you can drag your button to where ever you want it (taskbar, desktop, panel etc.) Then you can simple push the button to toggle samba on and off.
This is a nice colour laser printer that I managed to pick up quite cheaply with 2 sets of toner.
Problem
On my system (kubuntu 9.10 x86_64) it did not appear in lsusb and dmesg showed the following:
[15208.550014] usb 1-6: new high speed USB device using ehci_hcd and address 10
[15208.701200] usb 1-6: configuration #1 chosen from 1 choice
[15208.741575] usblp0: USB Bidirectional printer dev 10 if 0 alt 0 proto 2 vid 0x413C pid 0×5516
[15208.741596] usbcore: registered new interface driver usblp
[15209.747326] usb 1-6: usbfs: interface 0 claimed by usblp while ‘usb’ sets config #1
Funnily enough it did appear in the list of devices in virtualbox, however I had no luck trying (and didn’t really want to) to install it virtually. So I decided I’d make use of the built in network abilities of the printer and plug it directly into the router (I didn’t do this initially as I wanted the printer in a different room to the router).
Solution
After setting the printer up on the network, I ensure logged into the web interface and changed the password from the default. I then followed this thread on the ubuntuforums which refers to this text for installing the “Fuji Xerox DocuPrint C525A” driver which is compatible with the dell 1320c.
The driver is an 32bit rpm by default (which is fine for redhat based os’s), you can use alien to convert the rpm to an deb, or you can just download a prebuilt deb from zoffix.com (Direct link. This is a 32 bit package still so we need to install it using “–force-architecture”
sudo dpkg -i fuji-xerox-docuprint-c525-a-ap_1.0-2_i386.deb –force-architecture
Once this driver is installed you can login to cups and configure your printer as you would normally (instructions below). However when you are required to select the printer you need to provide the ppd file manually if you have installed the driver
1 – Open a webbrowser and goto http://localhost:631/admin
2 – Click add printer
3 – Enter a name for the printer eg: dell1320c (spaces are not allowed)
4 – Enter the printer address. This is the ip address of your printer prefixed with “lpd://”. eg: lpd://192.168.1.121
5 – Either locate Fuji Xerox DocuPrint C525A or select the ppd directly which is located at /usr/share/cups/model/FujiXerox/en/FX_DocuPrint_C525_A_AP.ppd
6 – Memory Capacity should be 64MB, and Optional Tray Module should be 250 Sheet Feeder
7 – finish.
Bypass tray problem
You should now print a test page, however if you get the problem like me that the printer always attempts to load paper from the manual paper feed, you will need to change the paper source from bypass tray to tray 1 in each program you need to print with (hopefully there will be a fix for this, but in this cups there seems no option to set it)
Additional
I also noticed that this printer was covering each printed page with tiny yellow dots, which can be used to identify a printer (most likely for criminal matters).
I’ve heard a lot about CUDA, such as how it is 10,000% faster at cracking wireless passwords over a conventional program/hardware, but never really got around to testing it out before now. This post details the steps required to compile and setup CUDA 2.3 SDK and toolkit on ubuntu 9.10.
Downloads
You are required to have an Nvidia graphics driver (relatively new version) already installed. First download the CUDA toolkit and CUDA sdk from the Nvidia CUDA 2.3 download page.
Install the toolkit
# Make file executable chmod +x cudatoolkit_2.3_linux_64_ubuntu9.04.run # Run it as superuser sudo ./cudatoolkit_2.3_linux_64_ubuntu9.04.run
You now need to edit your .bashrc file in your home directory to include the paths (so your CUDA binaries can be found by the system)
export PATH=${PATH}:/usr/local/cuda/bin
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda/lib64
Note if you are using 32bit then “lib64″ should be replaced with just “lib”
Install the SDK
# Make file executable chmod +x cudasdk_2.3_linux.run # Run it as normal user ./cudasdk_2.3_linux.run
You should now have a NVIDIA_GPU_Computing_SDK folder in your home directory. Change directory into the C folder inside this one.
cd NVIDIA_GPU_Computing_SDK/C
In this folder is a make file which will compile all the Nvidia SDK and all the demos, in order for this to work in ubuntu 9.10 (x64) you will need to install several dependencies. By installing these before attempting to make will save you a lot of time, if you are getting errors please scroll down to the problems section to see if they are already covered.
# Install the necessary libraries sudo apt-get install freeglut3 freeglut3-dev libx11-dev mesa-common-dev libxmu6
Making and running demos
You can then run the make command, once this is ran all of the executables will be placed in NVIDIA_GPU_Computing_SDK/C/bin/linux/released . We can check that our computer has an useable CUDA device install by running the deviceQuery program:
cd ~/NVIDIA_GPU_Computing_SDK/C/bin/linux/released ./deviceQuery
This should output something similar to the following:
# ./deviceQuery CUDA Device Query (Runtime API) version (CUDART static linking) There is 1 device supporting CUDA Device 0: "GeForce GTX 260" CUDA Driver Version: 2.30 CUDA Runtime Version: 2.30 CUDA Capability Major revision number: 1 CUDA Capability Minor revision number: 3 Total amount of global memory: 938803200 bytes Number of multiprocessors: 27 Number of cores: 216 Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 16384 bytes Total number of registers available per block: 16384 Warp size: 32 Maximum number of threads per block: 512 Maximum sizes of each dimension of a block: 512 x 512 x 64 Maximum sizes of each dimension of a grid: 65535 x 65535 x 1 Maximum memory pitch: 262144 bytes Texture alignment: 256 bytes Clock rate: 1.47 GHz Concurrent copy and execution: Yes Run time limit on kernels: Yes Integrated: No Support host page-locked memory mapping: Yes Compute mode: Default (multiple host threads can use this device simultaneously) Test PASSED
Now that we can see CUDA is successfully installed and a suitable device is found we can run some of nvidia’s more ascetically pleasing demos:
./fluidsGL
./smokeParticles
./particles
./postProcessGL
Problems
libxi (Nvidia forum link) make[1]: Leaving directory `/home/mat/NVIDIA_GPU_Computing_SDK/C/common' make[1]: Entering directory `/home/mat/NVIDIA_GPU_Computing_SDK/C/common' In file included from ./../common/inc/paramgl.h:24, from src/paramgl.cpp:19: ./../common/inc/GL/glut.h:60:20: error: GL/glu.h: No such file or directory make[1]: *** [obj/release/paramgl.cpp.o] Error 1 make[1]: Leaving directory `/home/mat/NVIDIA_GPU_Computing_SDK/C/common' make: *** [lib/libparamgl.so] Error 2
sudo apt-get install freeglut3 freeglut3-dev libx11-dev mesa-common-dev
/usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitf(float)’ cannot be declared weak /usr/include/bits/mathcalls.h:350: error: inline function ‘int __signbitl(long double)’ cannot be declared weak /usr/include/bits/mathinline.h:36: error: inline function ‘int __signbitf(float)’ cannot be declared weak /usr/include/bits/mathinline.h:42: error: inline function ‘int __signbit(double)’ cannot be declared weak /usr/include/bits/mathinline.h:48: error: inline function ‘int __signbitl(long double)’ cannot be declared weak /usr/local/cuda/bin/../include/math_functions.h:442: error: inline function ‘int __signbitl(long double)’ cannot be declared weak make[1]: *** [obj/release/particleSystem.cu.o] Error 255 make[1]: Leaving directory `/home/mat/NVIDIA_GPU_Computing_SDK/C/src/particles' make: *** [src/particles/Makefile.ph_build] Error 2
The problem is due to having gcc 4.4 installed rather than 4.3, it is possible to install the older version of this compiler but it is simpler to modify common/common.mk and add the following extra flag (Nvidia forum link):
# Change: NVCCFLAGS += --compiler-options -fno-strict-aliasing # To: NVCCFLAGS += --compiler-options -fno-strict-aliasing --compiler-options -fno-inline
and change the -O2
# Change: COMMONFLAGS += -O2 # To: COMMONFLAGS += -O0
The two remaining errors you may encounter are very similar and arrise from missing libraries:
libxi (Nvidia forum link)
/usr/bin/ld: cannot find -lXi collect2: ld returned 1 exit status make[1]: *** [../../bin/linux/release/particles] Error 1
sudo apt-get install libxi-dev
libxmu (Nvidia forum link)
/usr/bin/ld: cannot find -lXmu collect2: ld returned 1 exit status make[1]: *** [../../bin/linux/release/particles] Error 1
sudo apt-get install libxmu-dev libxmu6
So you want to use the nice notification features available in your desktop environment (KDE or Gnome) from a script you wrote? Below explains how to do just that for the two different environments.
KDE
The code below will use kdialog (should be installed along with kde) to create a popup message that displays for 3 seconds before closing:
kdialog --passivepopup 'notification message!' 3
This should look like the image below:
Source: stackoverflow
Gnome
A similar tool is available for gnome, but to the best of my knowledge (I don’t really use gnome) you need to install a package. The libnotify-
sudo apt-get install libnotify-bin
The command notify-send can then be used to create notifications from your script.
notify-send -t 3000 "notification title" "notification text"
Where 3000 is the timeout in milliseconds (so 3 seconds). notify-send features some nice additional options such as the ability to include images eg:
notify-send -i /home/user/exampleicon.png -t 3000 "notification title" "notification text"
Source: Coder’s Talk
When creating any non-trivial program using a versioning system is essential, especially when working in part of a group. This guide aims to be a quick tutorial to the SVN (subversion) tool for versioning and how to use it with an android project.
Assumptions
-
You will need SVN installed on your computer. This can be done using your package manager or by the following command in ubuntu / debian based systems:
sudo apt-get install subversion
-
You already have an SVN repository configured. If not please view a tutorial like this or if you have a nice webhost like me (thanks dreamhost
) there may be a simple tool to do this automatically for you in your panel.
Note
Don’t include the files inside /bin or /gen as they are just build from the source code and will simply fill up a lot space in your SVN. But do include the folders themselves as the project will fail to build without them.
Command line (recommended)
For SVN, I am a great fan of the command line. From the few SVN GUI applications that I have used in the past I can recommend Turtoise SVN for windows and kdesvn for linux (kde) but I still prefer the command line.
The following code will checkout the project from your server. This will create a new folder called “projectname” on your computer and download the project from your server (at this point it is most likely an empty folder).
# Checkout the SVN directory svn co svn.yourdomain.com/projectname projectname
You can then copy or create your android project in this directory. In our project folder there are two folders which contain generated files (as opposed to source files) there is no point uploading these to the svn as you will simply take up space and bandwidth. Before you decided to upload your changes to the server you should empty the bin and gen folders:
# Empty bin and gen folders rm -rf ./projectname/bin/* rm -rf ./projectname/gen/*
Each time you add a new file to the project you will need to add (`svn add filename` for single files or `svn add *` for all files):
# Tell SVN we want to be versioning these files svn add projectname/*
When you are happy with your changes you can commit (`svn commit -m “message”`) your changes to the svn to create a new version, it is mandatory to include a message with each revision and it is best to be as detailed as possible with the changes made. This makes it much easier to hunt down where a bug or regression was introduced.
# Save the changes and upload to repository svn commit -m "Initial import of projectname"
Each time you commit or wish to upgrade what is stored locally to the latest version on the server you need to use the following:
# Update the locally stored version svn update projectname
Further points
Eclipse has a plugin to manage SVN download and install instructions can be found here.
The following is a simple bash script that will scan each ip address in a give subnet and report if they are alive (or accepting ping requests). The code creates processes for each ping so that it completes quickly rather than scanning each ip address sequentially.
Create a text file called “pinger.sh” and paste the following into it:
#!/bin/sh
: ${1?"Usage: $0 ip subnet to scan. eg '192.168.1.'"}
subnet=$1
for addr in `seq 0 1 255 `; do
# ( echo $subnet$addr)
( ping -c 3 -t 5 $subnet$addr > /dev/null && echo $subnet$addr is Alive ) &
done
Save and close, then it can be called from the command line like so:
sh pinger.sh 192.168.1.
This will scan from 192.168.1.0 to 192.168.1.255 and will return something like the following:
192.168.1.1 is Alive 192.168.1.105 is Alive 192.168.1.112 is Alive 192.168.1.149 is Alive
Bash: Script to convert .flv to mp3
Flash Video (.FLV) is currently a very popular format of online videos, inparticular youtube. This post explains how to use a simple script to extract the sound from a flash video file and turn it into an mp3.
In order for the script to work you will need to download ffmpeg (to decode the video) and lame (to encode the mp3). This can be achieve in ubuntu by opening a terminal and running the following or alternatively you can use your package manager GUI to search and download the packages for you.
sudo apt-get install ffmpeg lame
You then need to create a new file named “flv2mp3.sh” and paste the following into it using your preferred text editor (which hopefully isn’t VI). Save the file and then change the file permissions so that it is executable (by running:`chmod a+x flv2mp3.sh` in the terminal or via the gui in you file browser)
#!/bin/sh
# this script should convert files from FLV to WAV and then to MP3
echo " "
echo " Welcome to FLV to MP3 converter! version 0.1"
echo " "
infile_name="$@"
# exit if the user did not enter anything:
if [ -z "$infile_name" ]; then
echo " "
echo "You did not tell me the file name, so I will exit now."
echo " "
exit
fi
echo " "
ffmpeg -i "$infile_name" -acodec pcm_s16le -ac 2 -ab 128k -vn -y "${infile_name%.flv}.wav"
lame --preset cd "${infile_name%.flv}.wav" "${infile_name%.flv}.mp3"
rm "${infile_name%.flv}.wav"
echo " "
echo "OK. I'm done! Have fun!"
echo " "
exit
You should now be able to convert a flashvideo into an mp3 by running the following command (changing the filenames to fit your purpose):
sh flv2mp3.sh videofilename.flv
Extra: Youtube
In linux it might be worth noting that youtube downloads the flv’s to your /tmp folder and you can easily copy them or convert to mp3′s (Ensure video is completly finished loading).
Also there is an application called ‘youtube-dl’ which can be installed from the repositories
sudo apt-get install youtube-dl
and then run using
youtube-dl http://www.youtube.com/video_to_borrow
Of course it’s up to your moral guidance to decide what you can and can’t download.
Android is a brilliant smart phone operating system, this is the start of a short series of guides for starting to program applications for it using the android SDK.
Android SDK
Download the android SDK
Once downloaded untar the SDK
tar xvzf android-sdk_r04-linux_86.tgz
The SDK is not complete as additional files need to be downloaded in order to compile for different versions of android. Open the SDK and AVG management application by moving into the SDK folder and running the following.
sh tools/android
In the avaliable packages select the android versions you wish to develop for, and begin downloading them. Should this fail please read the next section, otherwise skip ahead.
Failing to download
If you cannot download from the google website, goto settings and select “force https://… source to be fetched using http://” and click save and apply.
If this still does not work (as was the case for me) it is possible that for some reason a configuration file was not created for this program, this can be solved by creating it manually:
echo sdkman.force.http=true > ~/.android/androidtool.cfg
Creating Android Virtual Devices
You can create virtual android phones using the SDK and AVD manager, click the Virtual Device tab and select new. Enter a name for the device, and a size for the sd card and simply click create AVD.
Once you’ve created you Virtual Device(s) it should look like the following:
You can test these virtual devices and see how nicely the phones are emulated. This is much more useful once you begin writing applications.
Eclipse
I would highly recommend using eclipse as it, along with the android plugin, greatly simplifies production and testing of applications.
Download eclipse from the ubuntu repositories (or from the eclipse website)
sudo apt-get install eclipse
If you do not already have java installed then you will need to install it.
sudo apt-get install sun-java6-jdk sun-java6-jre
You will need to add the following line to your .bashrc in your home folder so that the android tools can be used in eclipse (and other programs).
export PATH=${PATH}:/home/user/android/sdk/tools
* replace /home/user/android/sdk with the path to where you downloaded the SDK
Installing the android plugin for eclipse
Google’s eclipse plugin install guide.
In eclipse goto help then Install new software and then add the google plugin url
https://dl-ssl.google.com/android/eclipse/
Then install Android DDMS and Android Development Tools.
Should you receive errors (like I did) relating to a missing package you will need to add the eclipse repository and install the missing packages.
http://download.eclipse.org/releases/galileo
You should then have a fully working eclipse with android plugin.
What next?
Now you should have everything setup in order to develop and android applications. I would recommend the google tutorials:
Free
Using the free command gives output something like this (-m just tells free to output in megabytes):
free -m
total used free shared buffers cached
Mem: 2013 1996 17 0 27 1381
-/+ buffers/cache: 588 1425
Swap: 956 0 956
This is useful but annoying as it doesn’t show you how much memory is actually free. Files that are used are kept in the ram (referred to as caching). If the memory is needed it is simply overwritten, however if the file is used again it is already in the memory which saves time.
I wrote a quick little bash line to get the actually memory in use or the actual memory free. I use grep to select the right line from the output of free, and then use awk to do the string manipulation and math.
Memory in use
free -m | grep Mem | awk ‘{x=$3-$7; print x}’
Memory free
free -m | grep Mem | awk ‘{x=$2-($3-$7); print x}’























