Subscribe Now

ABC, 123, Ruby, C#, SAS, SQL, TDD, VB.NET, XYZ

Friday, November 9, 2007

Fun with

It's fun to occasionally take a stroll through see what kinds of web services folks are creating.

Here are some of the ones I found interesting in my look today.

Convert Text to Braille

Here is a neat and easy to use service for converting text to Braille. The BrailleText conversion method takes two parameters, the text you want to convert (string) and the font size for the output (float). It returns a byte array that is easily converted into a JPG and displayed on a WinForm.

private void button1_Click(object sender, EventArgs e)
net.webservicex.www.Braille svc = new;
byte[] response = svc.BrailleText(this.textBox1.Text, 20);
using (FileStream fs = new FileStream("braille.jpg", FileMode.Create, FileAccess.Write))
foreach(byte b in response)

Text to Braille winform

How to convert the image to actual Braille that the blind can read...hmmm...looks like there are many possibilities there.

Dates of U.S. Holidays

This web service offers methods for discovering the dates of U.S. holidays for the year of your choice. For example, the GetThanksgivingDay method requires that you pass it a year value (integer) and it returns a DateTime value. I wired this service up to a simple ASP.NET page containing a calendar control and show this year's and next year's holidays, disabling selection of those dates as well.

Imports System.Collections.Generic

Public Class Holiday
Public Sub New(ByVal d As DateTime, ByVal nm As String)
Me.Date = d
Me.Name = nm
End Sub
Public [Date] As DateTime
Public Name As String
End Class

Partial Class _Default
Inherits System.Web.UI.Page

Private holidays As New List(Of Holiday)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim svc As New com.holidaywebservice.www.USHolidayDates()
For yr As Integer = DateTime.Now.Year To DateTime.Now.Year + 1
holidays.Add(New Holiday(svc.GetChristmasDay(yr), "Christmas"))
holidays.Add(New Holiday(svc.GetIndependenceDay(yr), "Independence Day"))
holidays.Add(New Holiday(svc.GetLaborDay(yr), "Labor Day"))
holidays.Add(New Holiday(svc.GetMartinLutherKingDay(yr), "MLK Day"))
holidays.Add(New Holiday(svc.GetMemorialDay(yr), "Memorial Day"))
holidays.Add(New Holiday(svc.GetNewYear(yr), "New Year's Day"))
holidays.Add(New Holiday(svc.GetPresidentsDay(yr), "President's Day"))
holidays.Add(New Holiday(svc.GetThanksgivingDay(yr), "Thanksgiving"))
End Sub

Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
For Each h As Holiday In holidays
If e.Day.Date.Year = h.Date.Year AndAlso e.Day.Date.DayOfYear = h.Date.DayOfYear Then
e.Cell.Text = h.Name
e.Cell.Enabled = False
End If
End Sub
End Class

U.S. Holidays on a Calendar

While the intent of this web service is quite nice, sadly it provides incorrect results as you can see in the image above (Christmas on the 24th? New Year's Day on Dec 31st?). This just illustrates that there are dangers in using black box web services that live "out there in the wild."

Daily Dilbert Cartoon

And last, but not least, this delightful web service serves up the URL of the

Dilbert Cartoon of the day (or the bytes of the JPG). I used the GetDailyDilbertImagePath method (no arguments) to return the URL (string) of the cartoon JPG location and plug that into a picturebox on a WinForm. Very easy.

Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim svc As New com.esynaps.www.DailyDilbert()
Dim url As String = svc.DailyDilbertImagePath()
Me.Text = url
End Sub
End Class

WinForm displaying Dilbert cartoon of the day

No comments: