Daniel 'MaTachi' Jonsson

Category Archives: Applications

How to Get Your Playstation 3 Dualshock 3 Sixaxis Controller to Work on Linux

Jstest-gtk

To see if the controller works, install jstest-gtk (it’s in Ubuntu’s repository). It will list all connected game controllers and show which buttons are pressed and which not.

Install it with:

sudo apt-get install jstest-gtk

Xboxdrv

My Playstation 3 Dualshock 3 Sixaxis controller worked quite well, sometimes, without any drivers. But it was quite unreliable, and the L2 and R2 triggers wouldn’t get recognized in Euro Truck Simulator 2. A much better solution is to install and run xboxdrv to emulate it as a Xbox 360 controller when you want to play games.

Install xboxdrv:

sudo apt-get install xboxdrv

Start it with:

sudo xboxdrv --detach-kernel-driver

Press the Playstation button on the controller to get xboxdrv start receiving and processing the inputs from the controller. This will print a lot of text in the terminal. If you want to quit it, press Ctrl-c. When it’s running, open Jstest-gtk and see if the controller now shows up as a Xbox Gamepad instead, and if all buttons, triggers and joysticks work.

I connected my controller with a USB cable, so I can’t say if this will work through Bluetooth.

Got my first bitcents

I have known about Bitcoin for about two years. But the recent growth made me want to try it out, play a bit with it and see how it works. It’s a really fascinating currency which is revolutionizing payment.

To purchase my bitcents I used the Swedish Bitcoin trading site Kapiton. I transferred 60 SEK (~9 USD), which took about a day until it showed up on my Kapiton account. I got 0.05869422 BTC for that which I then transferred to my own maintained wallet.

There is a really cool website called blockchain.info where it’s possible to see all transactions made in the Bitcoin network. Here is a link to my public address where the transfer is visible:

I have spent a lot of time reading questions and answers on Stack Exchange’s Q&A site dedicated to Bitcoins, and there is really a lot of interesting technical details to learn about. I highly recommend checking out that site.

For Reddit users there is an active Bitcoin subreddit which is pretty fun to read.

I also stumbled upon a cool site where it’s possible to see the Bitcoin exchange rate in real-time:

In my opinion Bitcoins aren’t very useful today since not many sites take them. But it feels like it could be Internet’s equivalent to cash, because it makes it really easy for private persons, artists and smaller developers etc. to accept payment, instead of fiddling with Paypal and such solutions. With Bitcoins you can transfer money to anybody across the whole globe in about only 10 minutes for a really small transaction fee. That’s incredible, so I hope it takes off.

Allow Newer Clients to Publish Results to RoboRumble Server

If you have set up a RoboRumble server to Robocode and you want to be able to submit battle results from newer clients, do the following steps:

  1. Open upload_results.php in the server’s root folder.
  2. Edit the line:
    $version_allowed = array('1.7.3.0', '1.7.3.2');

    to something like:

    $version_allowed = array('1.7.3.0', '1.7.3.2', '1.7.4.3');
  3. Save and you are done!

bash bad interpreter with Robocode

The other day I downloaded Robocode, ran the unpacker and tried to execute the shell scripts within the Robocode folder. However, on Ubuntu I got the following error when I did that:

matachi:robocode$ ./robocode.sh
bash: ./robocode.sh: /bin/sh^M: bad interpreter: No such file or directory

To fix this install dos2unix by running:

sudo apt-get install dos2unix

Then run:

dos2unix robocode.sh

And now the script is runnable on Linux.

How To Live Stream Your Ubuntu Desktop

In this post I will show how I managed to set up a live stream of my Ubuntu 12.04 desktop to Justin.tv. Since Justin.tv is tightly connected to Twitch.tv, you can probably with very small modifications make this work with Twitch too.

Step 1.

Create a new file called stream.sh and paste the following text into the file:

#!/bin/bash
INRES="1680x1050" # input resolution
OUTRES="640x360"
OFFSET="1680,0"
FPS="15" # target FPS
QUAL="fast"  # one of the many FFMPEG preset
STREAM_KEY="your_stream_key"
URL="rtmp://live.justin.tv/app/$STREAM_KEY"

avconv -f x11grab -s "$INRES" -r "$FPS" -i :0.0+$OFFSET -ab 192k \
-f alsa -ac 2 -i pulse -vcodec libx264 -crf 30 -preset "$QUAL" -s "1280x720" \
-vol 11200 -acodec libmp3lame -ar 44100 -threads 0 \
-f flv "$URL"

You can get your stream key from this page:

Note that you probably want to change the OFFSET variable to 0,0. I have it because I only wanted to stream my second monitor, which is to the right.

More options to x11grab can be found here, such as draw_mouse and follow_mouse:

The script is based on the one found in this thread:

Step 2.

Update the script’s permissions from the terminal:

chmod u+x stream.sh

Step 3.

The video codec (-vcodec libx264) requires that you have this package installed:

sudo apt-get install libavcodec-extra-53

This did I find out in this Stack Overflow answer:

Step 4.

Start streaming by running:

./stream.sh

Audio

I’m not completely satisfied with the audio quality on the stream. I changed the bitrate argument in the script from 96k to 192k, and I added “-vol 11200″ to increase the audio volume since it was incredibly low. The quality is still not very good, so if you have a solution, please leave a comment.

The package pavucontrol in Ubuntu’s repository is an audio manager that has some more options than the pre-installed. However, I didn’t find anything that I had use of there, but maybe you have.

Firefox is Getting Slow and Uses Much Memory? Check This!

I read an interesting Mozilla page about zombie compartments:

Basically it’s allocated JavaScript memory for pages that wasn’t released when the pages were closed. Apparently these zombie compartments can be caused by poorly written add-ons and userscripts. If you visit about:compartments and see compartments for sites you have closed, you have zombie compartments.

To solve this, you can start by open Firefox in safe mode and see if the problem persist. If it doesn’t, enable the add-ons one after another to pinpoint which one is causing the memory leak.

Connect a VirtualBox Virtual Machine to the Local Network as a Regular Computer

To make a virtual machine in VirtualBox appear as a regular computer in the LAN:

  1. Open VirtualBox Manager.
  2. Right click on one of the machines that you have set up and click on Settings.
  3. Click on Network in the left sidebar.
  4. Set Attached to: to Bridged Adapter.

When you now start up the machine it should appear in the router as an additional connected computer.

Make Screenshots of Whole Web Pages Without an Extension

Mozilla has added a Command Line for developers to Firefox Nightly and Aurora. To activate it, do the following steps:

  1. Go to about:config.
  2. Search for devtools.toolbar.enable and double-click to enable that.
  3. Restart the browser.
  4. Press Ctrl + Shift + V to open the developer toolbar with the command line.

(I suppose it will be enabled and available on the Tools menu by default in Firefox 16 – 17.)

With this command line, you can make a screenshot of a whole web page by typing:

screenshot filename.png 0 true

Work with Multiple Terminals in a Grid in a Single Window

If you often find yourself with a lot of open terminal windows, I can recommend you to try out the the program Terminator. With it, it’s possible to have open multiple terminals in a grid in a single window.

Terminator

Screenshot of Terminator

Links: