Archive
Installing the Java plugin for Firefox
Problem
You have a Linux box (e.g. Ubuntu) and you want to run an applet in Firefox. It starts, but then it hangs, and you have no idea what the hack is going on.
My Case
I had Firefox 3.6.3 and I wanted to use OpenCms 7.5.1′s upload feature. The uploading is done via an applet that started but when I chose the file to upload and clicked OK, nothing happened. The CPU was on 100% and using the top command I noticed that a Java process is stuck. A bit later I figured out that it must be the Java plugin…
Solution
In Firefox, verify what Java plugin you have. Go to Tools → Add-ons → Plugins. Here I had the icedtea Java plugin. This is a crap, use the official Sun plugin instead.
Open Synaptic and remove this plugin. I also removed all openjdk packages.
Then install these:
sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin sun-java6-fonts
Now let’s see the list of alternatives:
sudo update-java-alternatives -l
Here I got this output:
java-6-sun 63 /usr/lib/jvm/java-6-sun
Set the official one:
sudo update-java-alternatives -s java-6-sun
Now restart Firefox and check the Java plugin again. You should see Java(TM) Plug-in 1.6.0_22 (or something more up-to-date).
Troubleshooting
If you cannot install sun-java6-jre because it’s not in the repository, add Canonical Partners to your software sources.
Credits
Find more info here.
Firesheep danger, protect yourself
I just read about a funny Firefox add-on called Firesheep that can capture login information on free wifis. (Video in Hungarian here, text in English here.)
At http://techcrunch.com/2010/10/25/firesheep/, two Firefox plugins are recommended. They force your Firefox to use the https protocol wherever possible.
I installed both. HTTPS Everywhere contains a list of predefined sites but it’s difficult to add a new site. Force-TLS is the opposite. So the two nicely complement one another :)
Update (20101109): you can find some more info here.
Split a large file
Problem
You have a large file and you want to split it up in several pieces of the same size.
Solution
Let’s say we want pieces of 50,000,000 bytes (50 MB approximately).
split --bytes=50000000 film.avi
By default, the output files are named as ‘xaa‘, ‘xab‘, ‘xac‘, etc., where ‘x‘ is the prefix and ‘aa‘, ‘ab‘, ‘ac‘, etc. are the suffixes.
Use the command cat to put them together:
cat xaa xab xac >out.avi
Or simply:
cat x* >out.avi
Variation:
split --bytes=50000000 -d film.avi pre-
Now the pieces will be named as pre-01, pre-02, etc. The switch -d means to use numeric suffixes.
One more:
split --bytes=50m -d film.avi pre-
Now the size of the output pieces is really 50 MB, i.e. 52,428,800 bytes.
Modify dependencies of a .deb file
Problem
You have a .deb file that doesn’t install because of some dependency problem. You want to tweak the list of dependencies yourself.
Example: under Ubuntu 10.10 I wanted to install Boxee TV. I downloaded the .deb file but it didn’t install. It said "Dependency is not satisfiable: libdirectfb-1.0-0|libdirectfb-1.2-0", though I had libdirectfb-1.2-9 on the system. So the natural solution is to modify the dependency from libdirectfb-1.2-0 to libdirectfb-1.2-9. This problem and its solution was provided here.
Solution
Here I found a nice script that allows you to modify a .deb file. It extracts the .deb file, you modify the dependencies, then it repacks the file. Easy. The script is the following:
#!/bin/bash # videbcontrol.sh , from http:// ubuntuforums .org/showthread.php?t=636724 if [[ -z "$1" ]]; then echo "Syntax: $0 debfile" exit 1 fi DEBFILE="$1" TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1 OUTPUT=`basename "$DEBFILE" .deb`.modfied.deb if [[ -e "$OUTPUT" ]]; then echo "$OUTPUT exists." rm -r "$TMPDIR" exit 1 fi dpkg-deb -x "$DEBFILE" "$TMPDIR" dpkg-deb --control "$DEBFILE" "$TMPDIR"/DEBIAN if [[ ! -e "$TMPDIR"/DEBIAN/control ]]; then echo DEBIAN/control not found. rm -r "$TMPDIR" exit 1 fi CONTROL="$TMPDIR"/DEBIAN/control MOD=`stat -c "%y" "$CONTROL"` vi "$CONTROL" if [[ "$MOD" == `stat -c "%y" "$CONTROL"` ]]; then echo Not modfied. else echo Building new deb... dpkg -b "$TMPDIR" "$OUTPUT" fi rm -r "$TMPDIR"
Credits
Get favicon from a website
Problem
There is a nice favicon associated to a website that you want to extract. How to do that?
Solution
Well, the easiest way is to visit http://www.getfavicon.org/. Just type in the web address and let it do the job for you. At the end you save the image.
Notes
If you want to do this with a script, this post can give you some ideas.
Remove the newline character from a text file
Problem
I had a text file that contained only one line. For some reason I wanted to remove the trailing newline character (‘\n‘). However, it’s not that easy :) Most text editors automatically add a newline after every line. This is a normal behaviour actually, every line should end with a newline character. But if you want to get rid of it, how to do that?
Solution
You can remove the trailing newline with a hex editor. In the Ubuntu repositories I found hex (from package ‘hex‘) and ghex2 (from package ‘ghex‘). The first one, hex, is very simple, it just prints out the contents of a file, similarly to cat. It is good to identify the newline character. To edit the file, you can use the latter, ghex2.
Test
To test your favourite text editor, create a simple file that contains the word “test”, without quotes (i.e. 4 characters). Do not press ENTER at the end. Save it and check its size. If it’s larger than 4 bytes, then the newline character was added automatically. With the command hex you can verify it.
Copy a project folder without the .svn subdirectories
rsync -r --exclude=.svn $SRC_DIR $DEST_DIR
This tip is from here.
Remove .svn directories recursively
find . -name .svn -print0 | xargs -0 rm -rf
Be careful where you execute it because it will remove all .svn subdirectories!
Call phone from Gmail
Recently, Google added a cool feature to Gmail. Now you can make international phone calls, i.e. you can call fix and mobile numbers too. In the US and Canada it’s FREE, and you can make international calls for a very low price. For instance, I can call Hungary from Canada for 0.02 CAD. Pas cher ! :) More info here. International calling rates here.
How to have it? First, you must enable it in Gmail in Settings -> Chat. Here next to Call Phones choose “Enable”. Then, in the bottom left corner a new link should appear that says “Call phone”. When you click on it, you will be asked to install a plugin. I tried it under Ubuntu and Windows, works fine.
I also had 0.10 CAD on my account which gave me 5 minutes of talk. If you like the feature, you can add credit to your account. Actually, I use it together with Skype. If somebody is not online, I call him on his fix/mobile number and ask him to start Skype. If he’s OK, we can continue the conversation on Skype for free.1
1Note that the masculine gender has been used for simplicity only ;)
dropbox installation
To install dropbox, visit the page https://www.dropbox.com/downloading?src=index. In short, you need to do the following:
- Install the
.debfile. - Install Dropbox’s public key (
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5044912E).
Then you will find Dropbox under Applications -> Internet.
Update (20130309)
Here is how I installed Dropbox under Ubuntu 12.10.
$ sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5044912E $ sudo add-apt-repository "deb http://linux.dropbox.com/ubuntu quantal main" $ sudo apt-get update $ sudo apt-get install dropbox