Move Linux Mint Root Partition
I recently added a new disk drive to my workstation and, as part of reorganising, wanted to move the Linux Mint root partition from one disk to another. Naturally I googled duckied it and found a certain amount of useful info.
I used gnuparted to copy the partition from one disk to another. The standard method to reinstall grub on a partition so it will boot appears to be to mount it and use grub-install with the –boot-directory option like this.
Read more →Handlers in Android
Using a handler to return results from a worker thread
This has taken me quite a while to put together. There are throw-away remarks in the Android docs about this, but no useful examples. You want to get the results back from a worker thread to your main activity so you can do stuff with them. There are several parts to this.
- The main activity implements Handler.Callback, and has a handleMessage function.
- When the worker thread is created, include a reference to the main activity.
- In the worker thread constructor, create a Handler, including the reference to the main activity.
- When some results need passing back, send a Message back to the main activity using the handler.
public class MyActivity extends Activity implements Handler.Callback
{
//...
// On create
@Override
public void onCreate(Bundle savedInstanceState)
{
//...
WorkerThread worker = new WorkerThread(this);
//...
public boolean handleMessage(Message msg)
{
//...
public class WorkerThread extends Thread
{
Handler handler;
//...
// Constructor
public WorkerThread(Handler.Callback callback)
{
handler = new Handler(callback);
//...
private void someFunction()
{
handler.sendEmptyMessage(WHATEVER);
// or
Message msg = handler.obtainMessage(WHATEVER, thingy);
handler.sendMessage(msg);
//...
The handler will send the message back to the activity in the UI thread, so you can do whatever with the contents.
Read more →Search Engine Optimisation (SEO)
I haven’t worried too much about search engines since I set this site up. I registered it with Google initially, and after a few days it appeared in the results, so that was good enough for me. If you search for Old Shoreham Buccaneers, or a subset of that, the Buccaneers site appears high in the results, job done.
Since I published a recipe based on the BBC TV programme Italy Unpacked about a month ago, I have been getting a lot of hits on the Recipes page. When I finally got around to checking I found that this is due to it being the only actual recipe directly attributed to the show in the search results. It’s currently fourth now second in the listing if you search for sausage and lentils recipe Italy Unpacked on Google.
Fast Fourier Transform
I wrote a java tuner app a few years ago, so I needed a Fast Fourier Transform to do the frequency detection. I found a fairly simple implementation in java on the web somewhere, can’t remember where, tried it, and it worked fine. The frequency detection algorithm comes from The Dsp Dimension.
A few years later I ported it to windows, added a few gizmos for tuning accordions and put it on Google Code. I was concerned that the FFT implementation was simplistic and did more research online to find better implementations. However, when I actually checked the performance with a profiling tool, I found that the spectrum display code was the bottleneck and the FFT was not significant. I tried a few different FFT implementations anyway, but they didn’t make a significant difference. I then ported the app to OSX, which has a built in high performance DSP library, so no problem there.
Read more →Transfer contacts from iPhone to Android
I’ve been using an old iPhone 3G, and I’ve got myself a new Android phone. First off, I googled DuckDuckGo’d how to transfer my contacts and found lots of suggestions. First, I tried My Contacts Backup, but it wouldn’t install on the iPhone.
So I synced the contacts with my Hackintosh using iTunes, exported the contacts to a vCard file, transferred it to the phone by email and imported the file to the Contacts app on the phone. You need to ensure that all the contacts are selected when you export them. And delete the one for Apple that got in there at some stage.
Read more →