Projects

PQGenerator

GSAK Macro

GSAK (Geocaching Swiss Army Knife) is a powerful waypoint management tool for storing, filtering and managing geocaching waypoints.
For the past few months i’ve been holding a database of all the Geocaches in the UK. This requires me to keep renetering pocket queries which each contain the information for upto 500 geocaches.
These are filtered by date placed, and currently there is about 110 different queries requried to cover the whole of the UK. As a premium member it is possible to queue up 40 pocket queries.

With this in mind, I set about a way of speeding up setting up these queries.

Firstly, as there are caches being archived all the time I needed a way to get a complete list of the current caches, this I achieved by making a macro in GSAK as follows:
#*******************************************
# MacVersion = 1.0
# MacDescription = PQ Date Creator
# MacAuthor = Gareth
# MacFileName = PQCreator.gsk
# MacUrl =
#*******************************************

$output=""+$_NewLine
$output=$output+""+$_NewLine

MFILTER Expression=not($d_found) and not($d_Archived)
SORT by="placeddate"
$start=$d_PlacedDate
$i=1
$ended=false
While $ended=false

Goto Position=500
$end=$d_PlacedDate
#PAUSE Msg=DateFormat($start)+" - "+DateFormat($end)
MFILTER Expression=$d_PlacedDate>=$start and $d_PlacedDate<=$end and not($d_Found) and not($d_OwnerName="gse1986") and not($d_Archived)
SORT by="placeddate"
If $_FilterCount>500
$end=$end-1
#MsgOK msg="checked if filter"+DateFormat($end)+DateFormat($start)
MFILTER Expression=$d_PlacedDate>=$start and $d_PlacedDate<=$end and not($d_Found) and not($d_OwnerName="gse1986") and not($d_Archived)
SORT by="placeddate"
EndIf
IF $_FilterCount=0
#PAUSE Msg="No waypoints in filter, action cancelled"
endIf

If $i<10
$out="00"+NumToStr($i)
Else
If $i<100
$out="0"+NumToStr($i)
ELSE
$out=NumToStr($i)
EndIf
EndIf

$output=$output+""+$_NewLine+"allUK-"+$out+""+$_NewLine
$output=$output+""+DateFormat($start)+""+$_NewLine
$output=$output+""+DateFormat($end)+""+$_NewLine
$output=$output+""+NumToStr($_FilterCount)+""+$_NewLine
$output=$output+"
"+$_NewLine
SET $Data = PutFile($_Install + "\PQ.XML",$output)
$i=$i+1
$start=$end+1
MFILTER Expression=$d_PlacedDate>=$start and not($d_Found) and not($d_OwnerName="gse1986") and not($d_Archived)
SORT by="placeddate"
IF $_FilterCount > 0

ELSE
$ended=true
ENDIF
EndWhile

$output=$output+""+$_NewLine
SET $Data = PutFile($_Install + "\PQ.HTML",$output)

IF Left($Data,7) = "*Error*"
Pause Msg="$Data"
Cancel
ENDIF

FBCal

Like a lot of people, I use Google Calender to organise and store all my various calender items, and when I found that Facebook allows users to export their events feed in ICS format I thought this was great.
However, after a few weeks I noticed that on my phone (which is synched with Google Calender) a lot of events started showing up as just “busy” rather than telling me what the event was.

After looking into this I found the problem being that for “non-open” events they were listed as private in the ICS feed. This isn’t a problem for most applications, however Google Calender decides to not display the linked information.

Anyway, I came up with a quick PHP script which sites between Facebook and Google calender, allowing Google Calender to display the events properly :)

$ical="http://www.facebook.com/ical/u.php?uid=".$_GET[\'uid\']."&key=".$_GET[\'key\'];
$file=file_get_contents($ical);
$search="CLASS:PRIVATE";
$replace="CLASS:PUBLIC";
$output=str_replace($search,$replace,$file);
header("Content-Type: text/Calendar");
// Give the file a name and force download
header("Content-Disposition: inline; filename=calendar.ics");
print_r($output);

You then simply link to the page ie http://www.host.com/calender.php?uid=&key=

You can find your UID and Key by logging in, clicking “See All” on the right hand side of the home page, under events and then click “Export” at the top of the page. :)