• Home
  • About
  • Resume

Shorten URL in HelloTXT WordPress plugin

By , 12/28/2011 10:24 PM

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

By , 12/27/2011 5:14 PM

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 'ASP.NET: Delete file from server after TransmitFile command'»

How to comfortably read PDF books on Kindle Fire

By , 12/19/2011 3:26 PM

I have tons of books on programming and many of them are accompanied by CD with the book in PDF format. A bright idea struck me – why carry around ton of bricks, when I can load electronic version onto my Kindle Fire? And it worked quite nicely, though a (very) little work required beforehand

PDF on Kindle Fire
Continue reading 'How to comfortably read PDF books on Kindle Fire'»

Kindle Fire as an Android Tablet

By , 12/16/2011 10:14 AM

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!

By , 12/10/2011 9:43 PM

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

By , 12/06/2011 1:53 PM

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.

Mac. Nobody gives a

By , 12/05/2011 11:48 PM

On the other hand

VB for Android

By , 11/29/2011 3:23 PM

Found this gem today:

Basic 4 Android

It’s a Visual Basic IDE environment for developing Android apps. But unlike other similar solutions it does not require bloated runtime running on the device, Basic4Android easily compiles native APK app.

Don’t learn Java, utilize your existing Visual Basic skills instead. And the community of thousands of developers can be a huge help as well.

Also you’re in luck today. Download the trial, play around with it and if you like it – use discount code “bvqbet” to get 50% off any version! Here’s how:

  1. Visit purchase link: http://www.basic4ppc.com/android/purchase.html
  2. Select Plimus as your checkout option
  3. Enter coupon code bvqbet in the coupon code field
  4. Profit! You get a 50% discound off a regular price

Happy coding!

UltraWebGrid bug: Row is selected on mouse move

By , 11/15/2011 6:03 PM

Submitted for your approval an UltraWebGrid with CellClickActionDefault=”RowSelect” and SelectTypeRowDefault=”Single” – an ordinary down-to-earth grid. It also posses event handler AfterSelectChangeHandler, also nothing out of the ordinary. But in a minute the aforementioned grid will exhibit properties most unusual. As the alert message ahead reads: Infragistics Bug Continue reading 'UltraWebGrid bug: Row is selected on mouse move'»

ClientScript.RegisterStartupScript: script injected, but not executed

By , 11/08/2011 12:04 AM

This was one weird mystery. I have used ASP.NET’s method ClientScript.RegisterStartupScript countless times to inject client-side JavaScript into page’s markup from the server-side code and it always worked perfectly. This time I created a very basic page from scratch:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>My Page</title>
    <script type="text/javascript" src="script1.js" />
    <script type="text/javascript" src="script2.js" />
    <script type="text/javascript" src="script3.js" />
</head>
<body>
    <form id="xfrmMain" runat="server">
    </form>
</body>
</html>

And then injected client-side script into it:

ClientScript.RegisterStartupScript(Me.GetType, "JSCode", "ProcessData();", True)

where ProcessData() is function from one of the scripts, loaded in the HEAD tag. The script injected just fine, I got a beautiful insert at the bottom of the rendered page:

<script type="text/javascript">
//<![CDATA[
ProcessData();//]]>
</script>

The problem was – it didn’d do squat – the script did not execute. Why? Continue reading 'ClientScript.RegisterStartupScript: script injected, but not executed'»

Panorama Theme by Themocracy