Saturday, February 28, 2015

I have written an Android app that communicates to my Raspberry Pi over SSH (using JSch) but the issue is that in the App the IP address of my Raspberry Pi has been hardcoded at 192.168.1.109 - ideally it would be good to be able to give it a local name, something like garagedoor.local - something that won't change when the DHCP assigns a different IP address.

It turns out that the way to do this isn't difficult on the Raspberry Pi and most of work is in changes to the Android App needed to make it happen. I've numbered the steps 1-4.

2. Test on either Windows, Linux or Mac OSX that the Raspberry Pi is visible on the network with its new name of "garagedoor.local".

On Windows, you will need to have Bonjour Networking Services installed, which comes bundled with iTunes.
Run a cmd.exe prompt and type the command ping garagedoor.local -- you should get a response from your Raspberry Pi.

On Mac OSX, Bonjour Networking Services are installed by default.
In a bash terminal window, type the command ping garagedoor.local -- you should get a response from your Raspberry Pi.

On Linux, first ensure you have installed the avahi-daemon package.
In a bash terminal window, type the command ping garagedoor.local -- you should get a response from your Raspberry Pi.

3. Using NSD (Network Service Discovery) on Android to resolve the Raspberry Pi's service name.

Browsers and terminal programs on Android won't be able to resolve the garagedoor.local since to do this requires use of either the official Network Service Discovery library (supported by API Level 16 up) or the open source Java Zeroconf library named jMDNS.

In my case, I am using a custom app I wrote to communicate to the Raspberry Pi, so I have decided just to use the Network Service Discovery library.

4. Source code changes needed in the Android App to support NSD (Network Service Discovery)

Notes: (1) Below is just how I decided to implement it, you may want to separate the NSD related code out of the Activity into its own class, but for me that wasn't a problem. (2) I probably need to do something related to NSD in the Application lifecycle events of onPause(), onResume(), onDestroy() and onTeardown(). I haven't done that here yet.

4.A. Add some members to the Activity

I added this to my MainActivity but my app is small and so that's all I needed to do.

Saturday, February 21, 2015

Just came across this today. Previously had heard the association with the musical sharp symbol (#) to mean a pitch higher in tone, but this was the first time I'd heard that the # symbol can also be seen as a matrix of four small + symbols, hence C# stands for C++++, i.e. an increment to C++.

Java - this had a reputation on Windows at the time for slow performance, bad visuals and bad tools.

At this point, Microsoft came out with Visual Studio.NET, the .NET framework and a new language named C#, with the help of former Delphi & Turbo Pascal language designer Anders Hejlsberg. Most Windows developers got on board - compared to what came before it was a breath of fresh air. Since that time, .NET has remained a large player, especially in the corporate and business market.

Google has their own IDE, Android Studio and the open source Android SDK, which you can program using Java or any other JVM language. In the same way that .NET lets you use different .NET compatible languages such as C++/CLI and F#, Android supports other JVM languages like Scala, Clojure and Groovy, all of which let you cut down on the verbosity and boilerplate of Java.

Based on Android's market share and future employment prospects, Android is a decent choice for developers to try out. Compared to iOS, Android isn't as performant or profitable, but now it has a decent IDE, the weight of numbers, and the capability to use many Java FOSS libraries.

Saturday, August 30, 2014

Here's a quick checklist of the free software I usually install on new Windows machines ...

Browser: Firefox - still the best browser in my opinion, with a wealth of developer tools. Chrome is also good but I found it to be prone to crashing, so gave up on it. After installing Firefox, I remove the Internet Explorer link on the task bar.

DVCS (Distributed Version Control System): Git for Windows. Includes a command line shell which features decent help for all the git commands. You can use this to pull from and push to remote repositories hosted on services such as GitHub and BitBucket.

Flash: Adobe Flash Player. Be sure to uncheck the McAfee Anti-virus
installer option. I really hate installing Adobe software onto a new
PC. My only reason for doing it is for the many websites that still rely
on flash.

File archive/compression tool: 7-Zip supports many formats, such as zip, rar, gz and tar, is fast, and open source.

Media player: VLC Media Player. This is a great music and video player which also can be used to rip DVDs and CDs. After installing it, I remove the Windows Media player link on the task bar.

Text editor: Notepad++. An excellent replacement for Notepad which supports syntax highliting for probably every known programming language, including Golang, via a simple language syntax file.

PDF creation: PDF Creator installs itself as a printer on your system, so when you print to it, it prompts you for the PDF filename to create.

PDF viewer: Sumatra PDF. This is an extremely fast PDF viewer, written in C++. It has a simple, uncluttered user interface. It also supports other formats such as XPS. Makes a nice change from the bloated incumbents, Adobe Reader and Foxit Reader. Refreshingly there's no adware or spyware in the installer and they also offer a portable version (no install required).

Office software (spreadsheet, word processor, slideshow): Libre Office and Open Office are free alternatives to the more widely used Microsoft Office, which still claims top spot in the number of businesses using it. Try and get the discounted MS Office Student Edition, or a discounted MS TechNet license to save money on the standard price. This site offers digital downloads of the various MS Office installers, however you will still need a valid license key to install it.

Graphic file viewer: IrfanView is a compact and fast picture viewer for Windows. Its claim to fame is that it has been around forever (well at least since 1996) and is maintained by a humble dude from Bosnia called Irfan Skiljan (pronounced "Earfan") hence the name of the software. It has built in support for many file formats such as PCX, TIFF, RAW and other arcane formats such as those used on Amiga, Atari and Silicon Graphics machines. You can also use it to do batch format conversions.

Digital darkroom software: LightZone is a great free alternative to Adobe Lightroom. You'll just need to sign up for an account on their website before getting a download link.

3D graphics and animation: Blender is a free and open source 3D animation suite. It supports the entirety of
the 3D pipeline - modeling, rigging, animation, simulation, rendering,
compositing and motion tracking, even video editing and game creation.

3D modeling: SketchUp is an easy to use 3D modeling program. It has uses primarily in the fields of architecture, interior design, mechanical engineering and industrial design. Its free for personal and educational use. Their website has a large repository of 3D models that you can download.

Video editing: Blender mentioned above (under 3D graphics) can also do video editing, but for a standalone video editing program for Windows, one of the best available is Lightworks. The standard version is free, but they offer also paid pro version which has more advanced features. A decent alternative to Adobe Premiere. For only basic video editing, then the free Windows Movie Maker from Microsoft is a good option.

Password safe: KeePass. Comprehensive list of features, is open source, and is under active development.

Binary hex editor & viewer: FRHED (FRee Hex EDitor) is a great little program. What's more there's no installer, just a simple .exe file you can put anywhere you want. Great for viewing, editing and searching through binary files.

Task manager: Process Explorer by Windows guru Mark Russinovich is like the Windows Task Manager on steroids. You can find out which files and DLLs a particular process is using.

C# REPL: CShell is an interactive C# interpreter, also known as a REPL (Read-Evaluate-Print-Loop). Such tools are par for the course for scripting languages like Ruby (irb). CShell lets you try snippets of C# code or call a DLL in a couple of lines, without having to fire up a heavyweight tool like Visual Studio.

Install the low power (1.3V) RAM into the single slot - need to insert it at an angle fist, then push it downwards until it clicks into place.

From the bottom panel, remove the 2.5" HD cage (mine had two screws, but its meant to have 4) and install the 2.5" SSD into the cage. Connect the SATA cable to the hard disk. There's only one way it can be inserted, so you can't make a mistake. Screw the cage back onto the bottom panel. Replace the bottom panel onto the Brix.

Connect the power supply to the DC-in port.

Connect a monitor to either the HDMI or VGA port.

Connect a wired USB keyboard to the USB 2.0 port.

Turn on the Brix via the power button on the top.

Keep pressing the Delete (DEL) key on the keyboard about twice per second until the BIOS screen appears. Use Left/Right arrows to navigate between tabs.

Confirm that the RAM and SSD have been detected by the BIOS.

Change the operating system option to Windows 7. Note that the Brix requires the Windows 7 64-bit installer.

Save and exit the BIOS.

Switch off the Brix via the power button on the top.

STEP (2) PREPARING THE USB BOOT DRIVE FOR THE WINDOWS 7 INSTALLER

The following steps to be performed on a windows PC or Laptop...

Ensure you have a Windows 7 (64 bit) install disk ISO file. If you have only the DVD, as I did, you will need to rip it to an ISO file at this point, using the ImgBurn software for example. Leave the ISO filename the same as the disk label (default behaviour). N.B. ImgBurn has a notoriously sneaky installer that will install "conduit" search malware and other crapware if you don't read the installer options properly, and deselect all options apart from the first one, which is ImgBurn itself.

Download and run Rufus - a utility to help you create a USB boot drive from an ISO. Rufus is a standalone .exe file, no install is needed, which is awesome.

Connect to the laptop a USB drive with at least 4GB free space that will be formatted (erased).

If no drives appear at this point, its because Rufus defaults to only displaying USB flash drives. Press Alt-F to have it display all fixed USB drives.

In Rufus, select the target USB drive and also the source Windows 7 ISO file.

Select the option "create MBR for BIOS and UEFI computers" and also the NTFS file system. These should be the defaults after selecting the Windows 7 ISO.

Create the USB boot disk in Rufus. Leave the disk label the same as the original ISO (or DVD).

After Rufus has finished, disconnect the USB boot drive.

STEP (3) INSTALLING WINDOWS 7 FROM THE USB BOOT DRIVE

Connect the USB boot drive to a USB 2.0 port on the brix.

Turn on the Brix via the power button on the top.

Keep pressing the DEL key on the keyboard about twice a second until the BIOS screen appears.

In the BIOS boot menu, confirm the USB boot drive is detected. If it is not detected, you may need to boot one more time by powering the brix off then on. I think this is something to do with the USB boot drive not being ready for the BIOS, which boots very quickly. In the BIOS boot menu, press the '+' key to move the USB boot drive to the top position.

Save and exit the BIOS.

Go through the Windows 7 setup. You can do this just fine with only a keyboard and no mouse, using TAB, SHIFT-TAB, UP, DOWN, LEFT, RIGHT and ENTER to make selections as required.

After the Windows 7 installer has finished copying files and is starting the installation it will prompt you to restart the Brix. At this point, you should go into the BIOS and restore the boot setting to boot from the SSD first (not the USB boot drive). Alternatively, you can just turn off the USB boot drive at this point, before the restart occurs.

Connect a wired USB mouse to the USB 2.0 port vacated by the USB boot drive.

IMPORTANT NOTE FOR INSTALLING WINDOWS 8

Some
commenters below have reported getting an error when trying to install
Windows 8 at this point. The message from Windows is something like "windows could not update the computer's boot configuration". As suggested by commenter Tim Bailey, the solution is to update the BIOS to the latest version. You can download the BIOS update tool from the Gigabyte website.

From the page above, instructions for updating the BIOS: For DOS, please type flash.bat in the dos mode. For Windows, please select folder and type f.bat in the windows command prompt (cmd.exe). STEP (4) INSTALLING THE BRIX DRIVERS IN WINDOWS 7

After Windows has been installed and booted ok on the Brix, install the following drivers from the driver CD by copying everything on it to a USB thumbdrive on your laptop and then inserting into the blue USB 3.0 port on the side of the Brix.

On the Brix, in Windows:

WiFi+BT driver - just double click setup.exe to install. This gets WiFi and Bluetooth up and running - you can then connect to the Internet. Requires a reboot after install.

Graphics - just double click setup.exe to install. Requires a reboot after install.

USB3 - just double click setup.exe to install. Requires a reboot after install.

Audio - just double click setup.exe to install. Requires a reboot after install.

Chipset - just double click setup.exe to install. Requires a reboot after install. A comment by a reader in the comments section below (Warren Rushby, December 10, 2014) indicates that this step was vital for his i3 model, so installing this driver is recommended.

I personally didn't bother installing the other drivers as they either weren't required by me (e.g. LAN) or they seemed to be only for Windows 8 anyway. To be on the safe side, especially if you are having issues, its recommended installing all the drivers.

My boot time is 17 seconds from power on to the Windows 7 login screen. Not too bad, helped no doubt primarily by the SSD.

STEP (5) (OPTIONAL) CONNECT A WIRELESS KEYBOARD & MOUSE

In Windows, replace the wired USB mouse with a wireless USB mouse and wait for Windows to install the driver (takes a minute or two).

Replace the wired USB keyboard with a wireless USB keyboard and wait for Windows to install the driver (takes a minute or two).

I noticed a couple of times that the wireless mouse wasn't working. I had to unplug and replug its USB dongle, and that fixed it.

STEP (6) (OPTIONAL) INSTALL SOME WINDOWS SOFTWARE

At this point I installed this software, which I personally find are essential in Windows, although you might have differing opinions on each category. All are free.

Browser: Run Internet Explorer to download and install Firefox. Then I remove the Internet Explorer links on the task bar and desktop.

Flash: Adobe Flash Player. Be sure to deselect the McAfee A/V installer option. I really hate installing Adobe software onto a new PC. My only reason for doing it is for the many websites that still rely on flash.

Media player: VLC Media Player. Then I remove the Windows Media player link on the task bar.

Editor: Notepad++. An excellent replacement for Notepad which supports probably every known programming language, including Golang.

Small snippet of trivia to finish with ... the Gigabyte Brix was named after Colin Brix, who is a marketing director at Gigabyte's Motherboard Business Unit.

Saturday, August 31, 2013

Thanks to Harry Brignull from Dark Patterns for bringing up the interesting topic of evil user interfaces; UIs designed to trick you into spending more money, or buying a product you don't want. Here's the best example from their slidedeck - the Ryanair booking form. I've added some explanatory comments below each screenshot.

1. Ryanair home page.

Loads of sale fares for just £5, looks great ... lets buy a ticket ...

2. The booking form.

Looks straightforward so far, no issues yet.

3. Passenger details section.

Notice the default option for the insurance dropdown is "Please select a country of residence".If you're not paying attention, you'll assume it is just an address question, and so you'll select your country of residence. In doing so, you are actually selecting to pay for travel insurance ... its designed to trick you into selecting it by mistake.

4. Travel insurance dropdown.

If you don't want travel insurance, then you have to select the correct option, "No Travel Insurance", which is listed between Latvia and Lithuania.

5. On error, the dropdown clears your selection.

If you make a mistake anywhere on the form, such as shown above, forgetting to select "Yes" or "No" for the priority boarding question, then when you try and submit it, the insurance dropdown will default back to its original option, which was "Please select a country of residence". They really want you to pay for travel insurance, and this is their last chance of getting an extra few percent of users to buy it.

Saturday, June 22, 2013

After installing the Google Play Music app, the first screen allows you to choose which Google account to associate with it.

Seems straightforward enough; but have a look at the screen - what you would press?

Looks like there's a choice of two commands, either Add account or Not now. But there's another command there ... the email address is a clickable hyperlink, but there's no indication that it is - no underline or radically different font. The Add account button actually prompts you to type in a new email address, i.e. not the one listed. One of the most confusing UI designs I've seen lately.

As discussed in this StackExchange.UX post, there's no strict rule about it, but buttons usually perform a command and hyperlinks usually take you somewhere new.

To improve it, maybe there should be a "Use" button to the right of each email address.