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 · No Comments »

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 · 2 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 »

301 Redirects

Some sites like Myspace allow for the use of vanity URLs. For example, my page is located at http://www.myspace.com/jamesrohal. Although not all sites allow for the use of vanity URLs (like Facebook), you can make up your own using 301 redirects in the .htaccess file. For example, I can now link to my Myspace profile using the vanity URL: http://www.jamesrohal.com/myspace. Typically 301 redirects are more efficient than meta, CNAME, and Javascript redirects because the server checks the .htaccess file first before fetching any pages.

To create a vanity URL http://www.yoursite.com/vanityurl that links to http://www.somesite.com add the following to your .htaccess file.

Redirect 301 /vanityurl http://www.somesite.com

For example, I have the following in my .htaccess file.

Redirect 301 /facebook http://www.facebook.com/people/James-Rohal/43202602
Redirect 301 /myspace http://www.myspace.com/jamesrohal
Redirect 301 /diigo http://www.diigo.com/user/jjrohal
Redirect 301 /googlereader http://www.google.com/reader/shared/14670748227574963949
Redirect 301 /citeulike http://www.citeulike.org/user/jjrohal
Redirect 301 /lastfm http://www.last.fm/user/jjrohal
Redirect 301 /flickr http://www.flickr.com/photos/jjrohal
Redirect 301 /linkedin http://www.linkedin.com/in/jjrohal
Redirect 301 /thesixtyone http://www.thesixtyone.com/jjrohal/
Redirect 301 /youtube http://www.youtube.com/jjrohal
Redirect 301 /twitter http://twitter.com/jamesrohal
Permalink · Written on: 03-16-09 · 1 Comment »