Monthly Archives: December 2011

Shorten URL in HelloTXT WordPress plugin

HelloTXT is a very cool service that can post your updates to multiple social networks with a single click. You can feed it data in multiple ways from RSS feeds to Android phones. One such way is a small neat WordPress plugin by Matthew Phillips. Once installed in your blog it will ping HelloTXT whenever you write a new post, notifying all your connected services from Facebook to Twitter.

One small drawback of v1.0.1 of this plugin (current as of this writing) – if permalink URL of your post is very long (pretty ones tend to be) – it gets cut off during HelloTXT notification, since status update has to be within 140 characters length. But there’s an easy solution. Open PHP source of the plugin in any text editor and in function hellotxt_notification locate line:

$link = get_permalink($post->ID);

This is the line that gets permalink of your post. To replace it with shortened URL we can call API of TinyURL service:

$link = file_get_contents("http://tinyurl.com/api-create.php?url=".get_permalink($post->ID));

and Voila! short links are being sent to HelloTXT

ASP.NET: Delete file from server after TransmitFile command

It’s a common scenario: user needs to download a file from the server by clicking link or a button in your ASPX page. The server-side code for this is pretty straightforward and looks something like this:

Sub DownloadFile(ByVal i_sServerPath As String, ByVal i_sDisplayName As String)
   Dim oFile As FileInfo = New FileInfo(i_sServerPath)

   With Response
      .Clear()
      .ClearHeaders()
      .AddHeader("Content-Length", oFile.Length.ToString())
      .ContentType = ReturnContentType(oFile.Extension.ToLower())
      .AddHeader("Content-Disposition", "attachment; filename=" & i_sDisplayName)
      .TransmitFile(oFile.FullName)
      .End()
   End With

End Sub

The code accepts 2 parameters: i_sServerPath – full path to the file on the server and i_sDisplayName – file name that will be displayed to the user in the “Save As” dialog. Code also populates response headers based on file information. I use this handy function to populate ContentType based on file extention:

Function ReturnContentType(ByVal i_sfileExtension As String) As String
   Select Case i_sfileExtension
      Case ".htm", ".html", ".log" : Return "text/HTML"
      Case ".txt" : Return "text/plain"
      Case ".doc" : Return "application/ms-word"
      Case ".tiff", ".tif" : Return "image/tiff"
      Case ".asf" : Return "video/x-ms-asf"
      Case ".avi" : Return "video/avi"
      Case ".zip" : Return "application/zip"
      Case ".xls", ".csv" : Return "application/vnd.ms-excel"
      Case ".gif" : Return "image/gif"
      Case ".jpg", "jpeg" : Return "image/jpeg"
      Case ".bmp" : Return "image/bmp"
      Case ".wav" : Return "audio/wav"
      Case ".mp3" : Return "audio/mpeg3"
      Case ".mpg", "mpeg" : Return "video/mpeg"
      Case ".rtf" : Return "application/rtf"
      Case ".asp" : Return "text/asp"
      Case ".pdf" : Return "application/pdf"
      Case ".fdf" : Return "application/vnd.fdf"
      Case ".ppt" : Return "application/mspowerpoint"
      Case ".dwg" : Return "image/vnd.dwg"
      Case ".msg" : Return "application/msoutlook"
      Case ".xml", ".sdxl" : Return "application/xml"
      Case ".xdp" : Return "application/vnd.adobe.xdp+xml"
      Case Else : Return "application/octet-stream"
   End Select
End Function

It’s all good, but what if you need to delete the file from the server immediately after user downloaded it? Continue reading →

Kindle Fire as an Android Tablet

Got my Kindle Fire. I must say – I love everything about this device. It’s fast, powerful, with a very nice screen. There’re gazillion reviews out there, I am not going to repeat them, just mention what I did to make it truly perfect.

Since Fire is powered by Android OS there’s no limit to what can be done with it.

Amazon Kindle Fire as an Android TabletFirst, I rooted it. Mostly I did it so I can install Android Market. Amazon’s own AppStore is nice and all, but very limited comparing to Android Market (even if it has Market’s apps, usually they’re a few versions behind). Beware though – if you root your Fire, you will lose video streaming capabilities from Amazon, so what I did – rooted, installed Market, unrooted (luckily it’s a one-click operation with rooting app).

Second, even though I like Fire’s home screen with the carousel and everything, I am used to more traditional Android display, so I installed ADW Launcher and got 5 home screens, app drawer and all the bells and whistles. And still kept all Fire capabilities (Amazon video, music & books) via pre-installed apps, now available in app drawer.

And last, I installed Dolphin Browser HD to use instead of preinstalled Silk web browser, since Dolphin is much more capable, and superb FBReader to read my own collection of ebooks. Those two apps are permanently docked in my home screen.

I could go on and on, about how you can stream your own music and videos from your home PC via GMote app, how you can now install GMail, YouTube and any other Google app etc. etc. but that would take forever. The conclusion: Fire is an Android tablet and capable of anything Android Tablet can do.

Plants vs. Zombies 2!

Well, not really. But if you’re a fan of the original PvZ and just can’t wait for the sequel – check out this beauty:

“Mini Robot Wars” looks like a straight out clone of Plant vs. Zombies, but as clones go – this one is pretty good, give it a try!

UltraWebMenu: When background doesn’t change on hover in IE9

If you tried to use Infragistics classic UltraWebMenu control in IE9 you may experience issue (even in the latest version, 11.2 at the time of this post) whereby menu items don’t change background on mouse hover even though background is specified in menu’s HoverItemStyle property.

The solution is specify BorderStyle in HoverItemStyle. It can be any value besides NotSet, but the actual attribute has to be there. So for example if you want your hover style to have no borders and your original style looks like:

<HoverItemStyle
   ForeColor="White" 
   BackColor="#81C0E9"
   Height="18px"
   BorderWidth="0px"> 
</HoverItemStyle>

change it to

<HoverItemStyle
   ForeColor="White"
   BackColor="#81C0E9"
   Height="18px"
   BorderWidth="0px" 
   BorderStyle="None">
</HoverItemStyle>

I don’t know why border style affects showing of the background, but there you have it. Adding BorderStyle to HoverItemStyle will enable displaying of background color on hover.