Monday, July 28, 2008

Google Calendar Event Images

Many college are jumping on Google Apps to begin hosting student email. One of the features of Google Apps is the public calendar where you can post college events.

There are some limitations with Google Calendar:


  1. When you create an event you cannot add custom fields. There's no field for a brief description (teaser) or image.
  2. When I asked Google how to add additional fields they recommended using the API and writing a custom application that uses the google calendar database as a backend. Unfortunately I don't have the time or the resources to do that right now.

I wanted to be able to embed google calendar items in a webpage with a one line teaser and picture.

Example:

Screenshot


How did I do it?

To get around this I added the subject and the image to the description but google likes to strip out the html tags. I created a new event on my calendar and in the description box I typed:




This is my description of the event. It can be as long as I need. This is where I would type all the details that would show up after someone clicks the link.
<br>
Image: http://www.myurl.com/image.jpg
<br>
Subject: This is my teaser

I parsed the xml file created by google and extracted the image and subject from the description. I wrapped the image and subject in the proper html tags when I displayed the content on my webpage.

Here is what the Google Calendar XML file looks like: http://www.google.com/calendar/feeds/jazzerup%40gmail.com/public/basic

I found a free ASP script to display RSS/XML feeds - ByteScout (Big thanks to ByteScout for sharing your code with the world)


zip Download my modified version



I used regular expressions to extract the subject and image. Please note I'm awful at Regular Expressions but I found this great site where people share their completed expresssions: http://regexlib.com/

To install this code you'll need to change the URLToRSS = http://www.google.com/calendar/feeds/jazzerup%40gmail.com/public/basic
to your Google Calendar XML Address.


How do I find my Google Calendar XML Address?

It's a little tricky to find your XML Address

Step 1: Open your Google Calendar: http://www.google.com/calendar

Step 2: Click on "Settings" in the upper right hand corner.

Step 1


Step 3: Under the "Calendars" tab select your calendar.

Step 2

Step 4: Under "Sharing" click on "Sharing:Edit Settings"

step 3

Step 5: Under the "Share the Calendar" tab you need to make the Calendar Public in order for your feeds to show events.

Step 3

Step 6: Under the "Calendar Details" tab there are links to your XML, ICAL and HTML calendars.

step 4


step 5

Step 7: Click on the XML link and copy the address.

step 6

Sunday, July 27, 2008

Organize Files VBS

Organize Files by Extension VB Script

I have hundreds of gigs worth of files and difficulty finding anything. Before Windows Vista I found that searching for a file could take a half hour and I realized I needed a better way to get organized. I wrote this quick Vistual Basic Script to help organize my files into subfolders by extension and date modifed.




Below is a screenshot of my folders after my files have been copied to their destination.

How it works:
1) It looks at my source folder

2) Copies the file into a new destination (I didn't do move in case something wen wrong)

3) Places the files into a subfolder by its extension and daet modified (Example - test.doc) would go into a doc_2008 folder.

4) Create a log of each file moved (in case it crashes mid-stream I know the last file moved)

License: Open Source (GNU General Public License)


Code:


Dim varstartpath, vardestination

'IMPORTANT - You need to provide a source and destination path.
varsource = "S:\Users\"
vardestination = "R:\Backup"


OrganizeFiles(varsource)

WScript.Echo "Done!"

'-------function to Find File Extensions------------

Function GetExtension(varfile)

'------Split the file by periods--------------------
arrayperiods = Split(varfile,".")
'------Select the characters after the last period--
varnumperiods = UBound(arrayperiods)
'------Return the value to GetExtension
GetExtension = arrayperiods(varnumperiods)

End Function


'-------Sub Procedure to Create Folders Based on File Extensions and Date------------

Sub CreateFolder(varfile,vardate)

Set objFSO = CreateObject("Scripting.FileSystemObject")

'------Find out file extension-----------------------
varextension = GetExtension(varfile)
'-------------------

'------Create a destination folder based on the extension and the year modified
varfolder = vardestination & "\" & varextension & "_" & year(vardate)
'-------------------

'------If the folder doesn't already exist then create it
If Not objFSO.FolderExists(varfolder) Then Set objFolder = objFSO.CreateFolder(varfolder)
'-------------------

Set objFSO=Nothing

End Sub


'-------Sub Procedure to Copy Files to a Folder------------

Sub CopyToFolder(varpath,varfile,vardate)

varextension = GetExtension(varfile)
varfilesourcepath = varpath
varfiledespath = vardestination & "\" & varextension & "_" & year(vardate) & "\" & varfile

Set objFSO = CreateObject("Scripting.FileSystemObject")


'-----Keep a log of files moved so you know where it crashed------------------

'Create or append a text file

varlog = varpath

Set fso = CreateObject("Scripting.FileSystemObject")
fpath= vardestination & "\FilesMoved.txt"
flg=fso.FileExists(fpath)

If flg Then
Set floc= fso.OpenTextFile(fpath, 8)
floc.WriteLine(varlog)
floc.Close
Else
Set floc = fso.CreateTextFile(fpath,true)
floc.WriteLine(varlog)
floc.Close
End If

Set fso = Nothing

'--------------


'------Check to see if File Exists-------------------
If Not objFSO.FileExists(varfiledespath) Then



objFSO.copyFile varfilesourcepath,varfiledespath

Else

set objFileName = objFSO.GetFile(varfilesourcepath)
varsourcesize = objFileName.Size
varsourcemod = objFileName.DateLastModified
Set objFileName = Nothing

set objFileName = objFSO.GetFile(varfiledespath)
vardestsize = objFileName.Size
vardestmod = objFileName.DateLastModified
Set objFileName = Nothing

'------If the file was last modified at the same time and is the same size----

If (varsourcesize = vardestsize) and (varsourcemod = vardestmod) Then

objFSO.copyFile varfilesourcepath,varfiledespath,true

Else

'------If not true then rename the file-------
varyear = year(varsourcemod)
varsourcemod = FormatDateTime(varsourcemod,2)
varsourcemod = Replace(varsourcemod, "/", "_")
arrayperiods = Split(varfile,".")
varitemname = arrayperiods(0)


varfiledespath = vardestination & "\" & varextension & "_" & varyear & "\" & varitemname & "_" & varsourcesize & "_" & varsourcemod & "." & varextension

objFSO.CopyFile varfilesourcepath,varfiledespath,true

End If

End if


Set objFSO=Nothing

End Sub


'-------Sub Procedure to run through the files--------------------

Sub OrganizeFiles(path)

dim fs, folder, file, item, url

set fs = CreateObject("Scripting.FileSystemObject")
set folder = fs.GetFolder(path)

'Display the target folder and info.


'Display a list of sub folders.

for each item in folder.SubFolders
OrganizeFiles(item.Path)
next

'Display a list of files.

for each item in folder.Files

CreateFolder item.Name,item.DateLastModified
CopyToFolder item.path,item.Name,item.DateLastModified


next

set fs = Nothing


end sub

'----------

Text Message Notification

Nowadays email mailing lists are not nearly as popular or hip as text message lists.  There are service providers out there that charge you an arm and a leg for text messaging.  There are also free services like Twitter but it requires you join the twitter network.  I needed a quick an easy way to notify our technicans and managers of technology issues or outages.  I wrote this simple web application that allows you to send text messages based on subscribed categories. It is built in Dreamweaver using Classic ASP and runs on a Microsoft Access Database.


License: Open Source (GNU General Public License)

Demo Site
username: admin@admin.com
password: password

Note: This demo is intended to display the features and user interface. The ability to update the database has been removed.

Installation: On a windows server, unzip, upload, change permissions on the database to write and you're good to go.

Instructions:
1) Set your Categories
Categories are items that a user may want to be notifed about. 
Example:
  • ITS - You may want to set up your categories as different technology items (servers, phones, email, etc...)
  • Clubs & Services - You may want to set up your categories for different clubs and services services and notify students or users of upcoming events. 
  • Emergency - Categories can be different types of emergency notification.  However, given this is running off of an access database I wouldn't run it with more than 100 users.
2) Create Users

3) Select which users should be notified about which categories.

How it Works:  It's actually very simple.  It uses CDOSYS to send emails to the user's cell phone provider text message service. 

Enjoy and donations to my college fund are welcome =)