How to add USB wireless adapter to Raspbmc

I hate wires. So, I was happy to remove the ethernet cable from my Raspbmc setup and replace it with a USB wireless adapter. The steps are pretty easy:

  1. Get a USB wireless adapter. These are very cheap. I bought a DX Original USB wireless adapter, since I had read that it works out of the box with Raspbmc. Plug in the wifi adapter to your Raspbmc.

  2. Connect a wired or wireless mouse or remote to the Raspbmc. Use it for the configuration steps.

  3. Reboot the Raspbmc. This is needed sometimes for the mouse to be detected.

  4. Go to Programs > Raspbmc settings. In the Network Configuration tab change the Network Mode to Wireless.

  5. Configure the rest of the settings. The default is DHCP. If you want to use a static IP address, provide the necessary details.

  6. The scan for wireless networks did not work, it showed up empty. So, I manually entered the Wifi SSID (name of your wireless network), Wifi Security mode and the Wifi Key (wireless password). Click Update Now and OK.

  7. Your wireless adapter should be able to connect to your home network now. If not, reboot the Raspbmc.

  8. Unplug the Ethernet cable and enjoy your Raspbmc :-)

About these ads

How to understand C++ type declaration using cdecl

Type declarations in C or C++ can sometimes look confusing. cdecl is a commandline tool that can convert a type declaration into plain English that might be easier to understand.

To install cdecl:

$ sudo apt install cdecl

To use cdecl:

$ cdecl explain "const int* ip;"
declare ip as pointer to const int

To use cdecl in interactive mode:

$ cdecl
Type `help' or `?' for help
cdecl> explain const int* ip;
declare ip as pointer to const int

Note that I found that cdecl fails on even simple declarations which are legal in C or C++:

$ cdecl explain "const int const * ip;"
syntax error

The cdecl can also be used online here.

Tried with: Cdecl 2.5-13 and Ubuntu 14.04

How to get syntax highlighting for GLSL in Vim

GLSL shaders are typically written in standalone files. To get syntax highlighting for these files in Vim:

  • Make sure that the file has one of these extensions: .glsl, .vert, .frag, .geom, .vs or .fs.

  • Install the Vim-GLSL plugin:

$ cd ~/.vim/bundle
$ git clone

Tried with: Vim 7.4 and Ubuntu 14.04

File naming convention for GLSL shaders

Vertex, fragment and geometry shader programs can be written in GLSL. These are usually written in separate files. Any filename and extension can be used for GLSL shader files since the language standard does not enforce anything.

I found it convenient to name the shader programs as foo.vs.glsl, foo.fs.glsl and I found this convention used in the source code from the book The OpenGL Superbible. The .glsl is recognized by many editors and GLSL syntax highlighting is automatically applied when you open those files.

How to convert PDF to image

You may sometimes want to convert a PDF file into an image format like PNG or JPG. Doing this is easy using the convert application from ImageMagick.

If you do not have it, first install ImageMagick:

$ sudo apt install imagemagick

To convert a PDF with a single page into a JPG:

$ convert foo.pdf foo.jpg
$ ls

If the PDF has multiple pages, one image file is produced per page:

$ convert foo.pdf foo.png
$ ls

By default, the image file is produced at 96 DPI resolution of the PDF. If you need higher DPI, use the density option. For example, to generate at 300 DPI:

$ convert -density 300 foo.pdf foo.png

Tried with: ImageMagick 6.7.7-10 and Ubuntu 14.04