Dilbert Party

Translated using Translation Party.

9-3-09

Permalink · Written on: 09-03-09 · No Comments »

Subscribing To The NC State Calendar On Google

I’ve recently become enamored with Google Calendar and have been using it to keep tabs of everything. When I start attending NC State next fall I will attempt to use MyPack as little as possible. By doing so I lose the ability to see the upcoming events on the public events calendar. The school publishes an RSS feed of the calendar but I really want to be able to access the calendar in Thunderbird and Google Calendar.

My searching led me to this page which gave some code for parsing an RSS feed into a compatible ICS file. After some heavy modifications I was able to set up an iCalendar file I could subscribe to. I used an online iCalendar validator to make sure everything worked when I finished.

Hope this might be useful to someone else until NC State decides to publish their own ICS file.

Update: For those interested in keeping track of the mathematics department at NC State, I used the PHP Simple HTML DOM Parser to generate their calendar as an ICS file that you may subscribe to. It simply scrapes the data from the mathematics calendar.

Permalink · Written on: 06-21-09 · 1 Comment »

Updating Twitter from Mathematica

Since Twitter has become a way to instantly collaborate it seemed logical to implement a way to update your Twitter status from Mathematica. The method I created uses Web Services Link to access a WSDL based SOAP server automatically generated by NuSOAP.

First, download the latest version of NuSOAP and put it in a folder on your server. Let’s say this folder is called ‘twitter’ and is located in the root of your server.

Now we need to create the php file that will generate the WSDL service. Let’s call this file mathematica.php. Much of this code was adapted by Scott Nichol’s tutorial on Programming with NuSOAP using WSDL.

< ?php
require_once('lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('twitterupdate', 'urn:twitterupdate');
$server->register('Twitter',
    array('name' => 'xsd:string'),
    array('return' => 'xsd:string'),
    'urn:twitterupdate',
    'urn:twitterupdate#Twitter',
    'rpc',
    'encoded',
    'Provides the Twitter function to change your Twitter status using Mathematica'
);

function Twitter($status) {
	if strlen($status) < = 140 {
		$user = 'yourtwitterusername';
		$pw = 'yourtwitterpassword';
		$curl_handle = curl_init();
		curl_setopt($curl_handle, CURLOPT_URL, "http://twitter.com/statuses/update.xml");
		curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
		curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl_handle, CURLOPT_POST, 1);
		curl_setopt($curl_handle, CURLOPT_POSTFIELDS, "status=$status");
		curl_setopt($curl_handle, CURLOPT_USERPWD, "$user:$pw");
		$buffer = curl_exec($curl_handle);
		curl_close($curl_handle);
	} else {
		return "Your update must be 140 characters or less";
	}
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>

Now to access the WSDL file generated by mathematica.php we can go to http://www.yourserver.com/twitter/mathematica.php?wsdl. This WSDL service provides the operation named Twitter which will update the status for the username and password provided in the php file. The Update operation takes a string as its only argument.

Now to access the Twitter operation in Mathematica we must first load the WebServices package and then install the service provided by automatically generated WSDL file.

In[1]:= <<WebServices`
In[2]:= InstallService["http://www.yourserver.com/twitter/mathematica.php?wsdl"]
Out[2]:= {Twitter}
In[3]:= Twitter["I updated my Twitter status using Mathematica: http://tinyurl.com/mm2twitter"]

In the future I plan on creating a persistent session so you can use the InstallService to input your Twitter username and password. I would also like to support TinyURL generation.

Permalink · Written on: 04-05-09 · 4 Comments »

Fixing flickrRSS 5.0

If you are having difficulty displaying photos using the Wordpress plugin flickrRSS 5.0 you can make a quick change. Change line 144 which reads

if(!preg_match('<img src="([^"]*)" [^/]*/>', $item['description'], $imgUrlMatches)) {

to

if(!preg_match('/src=["]?(http:\/\/.*\/.*)_m\.jpg["]?/', $item['description'], $imgUrlMatches)) {

Source: Via chaosmaker at Google Groups

Permalink · Written on: 03-29-09 · No Comments »

Math / Computers / Bicycles

More things to be thankful for.

  1. Mathematics: Strangely enough my entire life has revolved around the field of mathematics. Although some people might see this as a bad thing I would have to admit I enjoy doing maths for a living. Not only does it force me to think logically but it will open up many career opportunities in the future. I can only hope that something I do in the future will contribute to society (or at least have some application).
  2. Computers: Without one I couldn’t make these blog posts! If I have to explain why I’m thankful that there are computers you clearly have not met me.
  3. Bicycles: In a crunch a car is a great way to get from one place to another but bikes, although slower, are just as reliable and great for the environment. My aunt recently provided me with a “new” Fuji Palisade. I say “new” because it is 20 years old but still in great condition.
Permalink · Written on: 03-24-09 · 1 Comment »