Sunday, May 09, 2010

 

This blog has moved


This blog is now located at http://threadeds.blogspot.com/.
You will be automatically redirected in 3 seconds or you may click here.

For feed subscribers, please update your feed subscriptions to
http://threadeds.blogspot.com/feeds/posts/default.

Monday, October 19, 2009

 

Manually start that background tasks thingy in XP

Some people never leave their Windows XP machine unused and unattended, so the background tasks that are normally run when the machine is idle don't get run and the machine becomes very slow. To manually start that background tasks thingy in XP just open up a command prompt and type in:

Rundll32.exe advapi32.dll,ProcessIdleTasks

Labels: ,


 

An XSLT to convert an XML file into a CSV


<xsl:stylesheet version="1.0

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

<!-- IF_THE_PIVOT_IS_A_SUBTYPE_IT_NEEDS_TO_GO_IN_HERE -->

>


<xsl:output method="text"/>"


    <xsl:template match="//PIVOT_GOES_IN_HERE">

        <xsl:apply-templates select="*" />

        <xsl:text>&#x0D;&#x0A;</xsl:text>

    </xsl:template>"



    <xsl:template match="//PIVOT_GOES_IN_HERE//*">

        <xsl:choose>

            <xsl:when test="count(child::*) > 0">

                <xsl:apply-templates select="*" />

            </xsl:when>

            <xsl:otherwise>

                <xsl:text>"</xsl:text>

                <xsl:value-of select="."/>

                <xsl:text>"</xsl:text>

            </xsl:otherwise>

        </xsl:choose>

        <xsl:if test="position() != last()">

            <xsl:text>,</xsl:text>

        </xsl:if>

    </xsl:template>


</xsl:stylesheet>


Labels:


Monday, October 12, 2009

 

In Memory of Common Sense

Today we mourn the passing of a beloved old friend, “Common Sense,” who has been with us for many years. No one knows for sure how old he was, since his birth records were long ago lost in bureaucratic red tape. He will be remembered as having cultivated such valuable lessons as:

- knowing when to come in out of the rain;

- the early bird gets the worm;

- life isn’t always fair; and

- maybe it was my fault.

Common Sense lived by simple, sound financial policies (don’t spend more than you can earn) and reliable strategies (adults, not children, are in charge).

His health began to deteriorate rapidly when well-intentioned but overbearing regulations were set in place. Reports of a 6-year-old boy charged with sexual harassment for kissing a classmate; teens suspended from school for using mouthwash after lunch; and a teacher fired for reprimanding an unruly student, only worsened his condition.

Common Sense lost ground when parents attacked teachers for doing the job that they themselves had failed to do in disciplining their unruly children.

It declined even further when schools were required to get parental consent to administer sun lotion or an aspirin to a student, but could not inform parents when a student became pregnant and wanted to have an abortion.

Common Sense lost the will to live as the churches became businesses and criminals received better treatment than their victims.

Common Sense took a beating when you couldn’t defend yourself from a burglar in your own home and the burglar could sue you for assault.

Common Sense finally gave up the will to live, after a woman failed to realize that a steaming cup of coffee was hot. She spilled a little in her lap and was promptly awarded a huge settlement.

Common Sense was preceded in death, by his parents, “Truth” and “Trust,” by his wife, “Discretion,” by his daughter, “Responsibility,” and by his son, “Reason.”

He is survived by his 4 stepbrothers – “I Know My Rights,” “I Want It Now,” “Someone Else Is To Blame,” and “I’m A Victim.”

Not many attended his funeral, because so few realized he was gone. If you still remember him, pass this on. If not, join the majority and do nothing.

Labels: ,


Monday, September 14, 2009

 

Make a 2GB SD card usable for an Oregon Scientific ATC2K

Formatting an SD card on an Apple Mac for use on equipment expecting a FAT16 file system can be non-trivial. I found the UI tools are not very good in this, often producing a FAT32 or other formants. I have found it more reliable to use the command line. Here is a sequence of commands I've found that create a reliable 2GB SD Card for use in an Oregon Scientific ATC2K helmet extreme sports video camera.

You need to find where the card is in the file system. Run this command both before and after inserting the card to find where it is
ls /dev/rdisk?

Assuming you discovered the card appears at rdisk6s1 from the command above.
Create a new FAT16 MS-DOS file system
newfs_msdos -v VOLUME_NAME -F 16 /dev/rdisk6s1

Now create a partition table
diskutil partitionDisk /Volumes/UNTITLED 1 MBRFormat "MS-DOS FAT16" "UNTITLED" 2000M

Now the card will appear on the desktop at UNTITLED.

Remember to eject from the desktop, so it can be used.

Labels: , ,


Monday, August 24, 2009

 

Ritter Classic 2009

The Ritter Classic is a fun cycle race held each year on Sjælland, Denmark. This year it again set off and ended in Taastrup, taking a route up to Ballerup, then east over to the coast and then hugging the shoreline travelled further north before heading back inland again, and just as it got above Taastrup, it headed directly south for the finishing line.

I expected to take between 5 and 6 hours, and quite surprised, not just myself, but supporters who wished to take photos of the team: we'd already passed by the time they arrived at the various photo ops. There were plenty of other photographers and several film crews from TV2 Sport amongst others. So I shall ask for some links when I find them.

My statistics:
118.8km in 4 hours 1 minute and 47 seconds,
Speed: averaged 29.5km/h with a maximum on 78.8km/h
Heart rate: average 140 bpm maximum 175 bpm
Cadence: average 83 rpm with a maximum of 125 rpm.

My route on Garmin Connect

Link to Google Earth kml file.

The Top 50 result list

Labels: , , ,


Monday, February 09, 2009

 

Minimal code to perform logging in Google Android

To produce log message in Google Android is really quite easy.

At the top of the file in the imports section add: import android.util.Log;

And then in your code you add Log.d(TAG,message);

Where TAG and message are strings.

It is considered good form that the TAG is a constant for the class.

So I put something like this at the top of the class private static final String TAG = Foo.class.getName();

There are several levels of logging and in level order these are Log.v(), Log.d(), Log.i(), Log.w() and Log.e()

Where
v = verbose
d = debug
i = info
w = warning
e = error

The logging is performed by LogCat which can be accessed via the adb tool that comes with the Android developer kit.

tools/adb logcat will start logging at the INFO level as that is the default.

tools/adb logcat *:V will log everything at VERBOSE level.

tools/adb logcat Wibble:W will filter most things and only show those log statements with the tag Wibble at the WARNING level.

Labels:


Thursday, February 05, 2009

 

Minimal code to display a Toast message in Google Android

Toast is a widget to display an informational message to a user whilst they may well be doing something else. I find it useful for debugging on a real device to tell me something internal to the application has been fired. Afterwards I can just strip such things out of the build.

				
// show the frost pist message using the Toast widget
Toast toast = Toast.makeText(context, "Woo hoo, toast", Toast.LENGTH_LONG);
toast.show();


I find the context is normally part of the method signature.
Toast.LENGTH_LONG keeps the message up for a few seconds.

There is a Toast.LENGTH_SHORT if you don't want the message to hang about for too long.

Labels:


 

Minimal code to retreive a GPS location in Google Android

Here I describe the minimal code to retrieve a GPS location in the Google Android OS.

First up, a GPS location listener.
				
class GPSLocationListener implements LocationListener {

public void onLocationChanged(Location location) {
double latitude = location.getLatitude();
double longitude = location.getLongitude();
}

public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}

public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}

public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
Somewhere else, probably in the Activity you need to tie this listener in. Here is an onCreate from a minimal application's Activity .
				
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

GPSLocationListener gpsLocationListener = new GPSLocationListener();

LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

long minTime = 600000;
float minDistance = 10;

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, minTime, minDistance, gpsLocationListener);

}
minTime is a request to the OS about how often to check the GPS location. If you set it less than 1 minute (60000) then you risk the battery going flat quickly because the GPS receiver will be on all the time. The number is just a request. The OS may request a fix more often, it may check less often.

minDistance is a request to trigger the listener when the device has moved by this distance.

You also need <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
in the applications AndroidManifest.xml file.

Labels:


 

Minimal code to send a SMS from Google Android

A minimal code for sending a SMS message from the Google Android OS.

This code assumes you're in an Activity , which is where it gets this :

				
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, new Intent(), 0)

SmsManager smsManager = SmsManager.getDefault();

String receiver = "5556"; // the phone number of the device to send the SMS message to.

String message = "This is the SMS message I want to sending";

smsManager.sendTextMessage(receiver, null, message, pendingIntent, null);


What it requires from this is actually just the interface to the Context .

The <uses-permission android:name="android.permission.SEND_SMS"></uses-permission> is also required your build's AndroidManifest.xml file

Labels:


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]