Techmeme recently added an events section to their website – see techmeme.com/#events  – that lists upcoming (and newsworthy) events focused on the tech industry. It’s a pretty useful list, curated by Techmeme editors, and includes tech events around new product launches, upcoming conferences, earnings calls of tech companies, webcasts, and related events.

The Techmeme blog has more details on how event organizers can get their own event listed on Techmeme. If you are organizing a Tedx or a BarCamp in your city, Techmeme may not find that very interesting but if you are doing a WordCamp that people like Matt {Cutts|Mullenweg} are attending, your event will probably make it to the Techmeme events page.

Subscribe to Techmeme Events in your Calendar

The Techmeme Events page currently doesn’t offer an ICAL / ICS feed so it is difficult to keep track of upcoming tech events in your Microsoft Outlook, Apple iCal or Google Calendar. There’s however a little workaround.

You can use either of the above links to add Techmeme events directly to your web / desktop calendar. These are standard ICS files that should be compatible with most calendar application across all platforms.

Thus, if Apple is scheduling an event during the first week of March, it should automatically pop-up in your calendar courtesy Techmeme. [Picture Credits: Wired]

The Source Code

The above ICAL/ICS files for Techmeme are generated with the help of some PHP and web scraping. The script basically downloads the Techmeme events page, extracts all the event related DIVs and formats everything in the iCalendar format. Should you be interested in enhancing / modifying the script, here’s the full source code:

<?php
$url  = "http://www.techmeme.com/events";
$day  = date("Ymd");
$file = 'techmeme.' . $day;
$feed = 'calendar.ics';

//Grab the Techmeme Events page once per day
if (!file_exists($file) || !file_exists($feed)) {
 $html = file_get_contents($url);
 $fp   = fopen($file, 'w');
 fwrite($fp, $html);
 fclose($fp);

//Declare header for Google Calendar
$header = "BEGIN:VCALENDAR
 VERSION:2.0
 PRODID:-//Techmeme//Events v1.0//EN
 CALSCALE:GREGORIAN
 METHOD:PUBLISH
 X-WR-CALNAME:Techmeme Events
 X-WR-TIMEZONE:UTC
 X-WR-CALDESC:Upcoming Tech Events curated by Techmeme";

$events = "";
$next   = false;
$year   = date("Y");
$html   = file($file);

//XPath for Event DIVs
foreach ($html as $line) {
 if(preg_match('/<div class="rhov">
       <a href="\/goto\/(.*?)"><div>
       (.*?)<\/div><div>(.*?)<\/div><div>
       (.*?)<\/div><\/a><\/div>/',$line, $match)) {
  $eventURL   = "http://" . $match[1];
  $eventDt  = $match[2];
  if(preg_match('/(.*)?-(.*)/', $eventDt, $date)) {
    $eventDt = $date[1];
  }
    
  $eventTitle = $match[3];
  $eventVenue = $match[4];
  $month = substr($eventDt, 0, 3);
  
  //Advance the year after December
  if ($month == "Dec")
   $next = true;
     
  if ($next && $month != "Dec")
   $eventDt .= " " . (date("Y") + 1);
  
 //Write an All-Day event to the Calendar  
  $events .= "\n" . "BEGIN:VEVENT";
  $events .= "\n" . "DTSTART;VALUE=DATE:" 
           . gmdate("Ymd", strtotime($eventDt));
  $events .= "\n" . "DTEND;VALUE=DATE:" 
           . gmdate("Ymd", strtotime($eventDt . " +1 day"));
  $events .= "\n" . "SUMMARY:" . $eventTitle;
  $events .= "\n" . "DESCRIPTION:" . $eventTitle 
           . " " .  $eventURL;
  $events .= "\n" . "UID:" . strtolower(ereg_replace
             ("[^A-Za-z0-9]", "", 
             $eventTitle . $eventVenue . $eventDt)) . 
             "@calendar.techmeme.com";
  
  if ($eventVenue != "")
   $events .= "\n" . "LOCATION:" . $eventVenue;
   
  $events .= "\n" . "END:VEVENT";
  }
 }

$header .= $events . "\nEND:VCALENDAR";
$fmeme   = fopen($feed, "w");

//Save the Parsed Events to a physical file
fwrite($fmeme, $header);
fclose($fmeme);
}

//Echo the Calendar .ICS file
header("Content-type: text/calendar; charset=utf-8");
header("Content-Disposition: inline; filename=$feed");
echo file_get_contents("$feed");
?>