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
Rundll32.exe advapi32.dll,ProcessIdleTasks
Labels: computer tips, Windows XP
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>
</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: programming
Monday, October 12, 2009
In Memory of Common Sense
- 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: joke, thought for today
Monday, September 14, 2009
Make a 2GB SD card usable for an Oregon Scientific ATC2K
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: ATC2K, extreme sports, old
Monday, August 24, 2009
Ritter Classic 2009
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: cycle race, cycling, Denmark, Ritter Classic
Monday, February 09, 2009
Minimal code to perform logging in Google Android
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: google android
Thursday, February 05, 2009
Minimal code to display a Toast message in Google Android
// 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: google android
Minimal code to retreive a GPS location in Google Android
First up, a GPS location listener.
Somewhere else, probably in the
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
}
}
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: google android
Minimal code to send a SMS from Google Android
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: google android
Subscribe to Posts [Atom]