Posts tagged HowTo

How to get logged-in username in Hudson?

Quick background

Have you ever thought your manager keeps shelling out more on your plate other than the officially tracked tasks? Do not feel bad. You are not alone :)

My manager recently asked me to clean up the build server we use for our project. To put simply, it was a mess. I ended up deciding to start from scratch. Looking around, we quickly zoomed in on Hudson. A great build/CI server. Met literally all my requirements (one of which is extensibility – with the source for Hudson available as open source, we could not have asked for more!).

After many Hudson code changes and UI customizations, we now have a great CI server up and running. One of the code changes I did is to a plugin called email-ext. This enables customizing many aspects of e-mail notification that gets triggered. Unfortunately the stock plugin missed one important thing (at least to us!) – no way to get the user name who triggered the build.

I added a new variable called BUILD_USER to email-ext. When used in the email-ext mail template, this will get replaced by the user who triggered the build. Our server is plugged in to our corporate active directory and this plugin will pick up the logged in user name.

You will find the source code and binaries down below. Note that this is based off 1.3.4.2 Hudson code and is running in our snapshot very well. YMMV and do enough testing before putting in production. Do send me any bugfixes you make, I will make them available for download.

How to use this?

Copy the HPI file to your Hudson web apps folder. Restart Hudson. Go to <your job> => Configure. Scroll down to “Editable EMail Notifications” section. Click on “content reference” help to make sure BUILD_USER is showing.

See the highlighted text shown below.

Any instances of BUILD_USER will be replaced by the current logged in user. In case of timer activated builds BUILD_USER will show “timer”. In case the build trigger reasons cannot be found out, BUILD_USER will be replaced with “<unknown>”.

More >

HowTo: Use Dosbox as a Quick & Dirty disassembler

Dosbox is an open source DOS emulator available for many OS flavors. Dosbox allows you to run any old DOS game, relive some of the golden games of DOS era. It has full support for multiple video standards (VGA, CGA, Tandy,…) and sound cards (Adlib, SB, …). Amazing program! I was even able to bring up Windows 1.0 under that :)

Not many use this powerful emulator as a disassembler though. I have used this technique to disassemble many programs with out resorting to IDA or Sourcer.

More >

HowTo: Fix "The response to the metaWeblog.newMediaObject method received from the weblog server was invalid"

Today I got this error message from WLW: “The response to the metaWeblog.newMediaObject method received from the weblog server was invalid“. Why did WLW think the response was “invalid“?? What exactly did it receive from Wordpress??

Luckily, WLW logs a lot more in the background. You can access that log file via Help -> About WLW. Click on the “Show Log Results” link in the dialog box. This will open the log folder.

Mine had this trace dump:

WindowsLiveWriter,21504,Fail,00020,18-Mar-2008 14:00:01.479,"WindowsLive.Writer.Extensibility.BlogClient.BlogClientInvalidServerResponseException: Invalid Server Response - The response to the metaWeblog.newMediaObject method received from the weblog server was invalid:
Invalid response document returned from XmlRpc server
at WindowsLive.Writer.BlogClient.Clients.XmlRpcBlogClient.CallMethod(String methodName, XmlRpcValue[] parameters)
at WindowsLive.Writer.BlogClient.Clients.MetaweblogClient.DoBeforePublishUploadWork(IFileUploadContext uploadContext)
at WindowsLive.Writer.PostEditor.WeblogBlogFileUploader.DoUploadWorkBeforePublish(IFileUploadContext uploadContext)
at WindowsLive.Writer.PostEditor.BlogPostReferenceFixer.FileUploadWorker.DoUploadWork(BlogFileUploader fileUploader)
at WindowsLive.Writer.PostEditor.BlogPostReferenceFixer.LocalFileTransformer.Transform(String reference)
at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.LocalFileReferenceFixupFilter.FixReferences(String reference)
at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.OnBeginTag(BeginTag tag)
at WindowsLive.Writer.CoreServices.LightWeightHTMLDocumentIterator.Parse()
at WindowsLive.Writer.CoreServices.HTML.HtmlReferenceFixer.FixLocalFileReferences(String html, ReferenceFixer fixer)
at WindowsLive.Writer.PostEditor.UpdateWeblogAsyncOperation.LocalSupportingFileUploader.UploadFilesBeforePublish()
at WindowsLive.Writer.PostEditor.UpdateWeblogAsyncOperation.DoWork()
at WindowsLive.Writer.CoreServices.AsyncOperation.InternalStart()"," at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at WindowsLive.Writer.CoreServices.Diagnostics.LogFileTraceListener.Fail(String message)
at System.Diagnostics.TraceInternal.Fail(String message)
at System.Diagnostics.Trace.Fail(String message)
at WindowsLive.Writer.PostEditor.BlogPostEditingManager.UpdateWeblog(Boolean publish)
at WindowsLive.Writer.PostEditor.BlogPostEditingManager.PostToWeblog(Boolean publish)
at WindowsLive.Writer.PostEditor.PostEditorMainControl.commandPostAndPublish_Execute(Object sender, EventArgs e)
at WindowsLive.Writer.ApplicationFramework.Command.RaiseEvent(Object eventKey, EventArgs e)
at WindowsLive.Writer.ApplicationFramework.Command.OnExecute(EventArgs e)
at WindowsLive.Writer.ApplicationFramework.CommandBarButtonLightweightControl.OnMouseUp(MouseEventArgs e)
at WindowsLive.Writer.Controls.LightweightControl.RaiseMouseUp(MouseEventArgs e)
at WindowsLive.Writer.Controls.LightweightControlContainerControl.OnMouseUp(MouseEventArgs e)

Pretty neat stack trace,eh? ;) It clearly shows that DoUploadWork() (Invoked by UpdateWebLog()) method fails for some reason. Armed with this knowledge, I took a look at my post. I had many pictures in that and my WLW was setup to upload pictures through XML RPC. So, obviously that was causing some kind of trouble. I traced down the big picture (size: ~0.7MB) in my post, resized it to 40K and published again. Voila, things worked perfectly!

I googled for the error message, since I wanted to know how other people solved this. Looks like increasing the memory size for PHP in the server side will also help. So, one of the following things should help you to solve this problem:

  1. If you have images embedded that need to be uploaded to the server, make sure they are not big. I don’t have any idea on the *optimal* size. I guess anything less than 100K should be ok.
  2. If still you are getting the same error, try increasing the memory_limit value in php.ini to 12M or 16M. Check this page for info on memory_limit. If you don’t have access to your server, you may have to talk with your host provider.

I believe the first solution will fix this error, in most of the cases. Do let me know in the comments, if you come across any other solutions.

Cleaning up your Hard disk

Yesterday I took some time off to clean my office systems – a Dual Xeon desktop and a T41p laptop. The effort would have cost me at least 2 days, if not for the following tools!

CCleaner CCleaner – The best utility for cleaning up the temporary files, IE/Mozilla/Opera cache and lots of other junk. This used to be called Crap Cleaner, If I remember right :-)

WindirStat Main Window
WindirStat – This tool allows you to visualize the file groups in your disk. There are umpteen number of tools out there that can do this, but I like the simplicity and effectiveness of this. Also, it runs off the shelf (no installation, I love it). Another thing I love about this small utility is its progress bars, it shows a pacman like character going from one end to the other, which is kinda cute! Check the images, click to enlarge.

Windirstat - Progress bar
Duplicate File Finder Duplicate File Finder – However organized you may be, you will be amazed to see what this tool digs out. It can apply CRC32 or MD5 on the files in your hard disk to find out the same content in multiple files. It takes its own sweet time to run, but very effective and highly recommended. An analysis on C:\ (120GB) is still running, almost 45mins now.

Let me know if you use some other tool not listed here.

Firefox memory leak fix – How To?

When I keep Firefox open for more than 2 hours, my system, a dual xeon with 2GB fast DDR, became extremely slow. I have the latest 2.0.0.2 version. A quick googling turned up many results on “Firefox leaking memory”, but nothing solved my problem. I tried EngTech’s solution & couple of other solutions. More tinkering around pointed me out to a plugin, which was the cause – Ad block plus! Removing it solved the problem, but now I need to find a replacement plugin.

If your Firefox is eating up memory, I suggest, start rootcausing by uninstalling the addons one by one. This’d atleast get rid of the addons from the problem space.

Below you can see the firefox memory consumption with and with out Adblock plus. Click the image to enlarge. More >

WP-Mollio comment_form hook fix – HowTo?

If you are using WP-Mollio theme in your Wordpress site, I’d suggest adding the comment_form hook in to your comments.php. Only if you have this statement, the plugins like “Subscribe-to-comments” will work.

How to add this hook?

  • Open comments.php
  • Find the lines of code shown below. You will find it near the end of the file.

<p><input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" /></p>
</form>
<?php // if you delete this the sky will fall on your head
endif; ?>

  • Add <?php do_action('comment_form', $post->ID); ?> just above </form> ending tag. Save the file.

This will allow all the plugins that depend on comment_form hook to work properly.

How to play XVID files in a DIVX certified DVD player?

XVID TO DIVX

Do you have one of those DVD players that can play DivX? The ability to cram in 4 or 5 movies in a single DVD5 disk is something that I simply loved, when I got one of these DVD players. Mine is a part of DAV DZ720 that I bought from eZone, Bangalore. It is DivX certified (up to DivX 6). It played all my DivX videos with out a hitch, in fact, the a52 (Dolby) codec is well understood by this player and beautifully handled.

Unfortunately I also have lots of movies in Xvid, which are happily ignored by this DVD player. So, what do I do to play all those content now? I had couple of options:

  • Reencode all the XVID I have to DIVX
  • Update my sony DVD player’s firmware

More >

Autoincrementing the Build Numbers in VC++


The option to automatically increment the build numbers (for successful builds) is one thing VC++ misses. AFAIK, VB & Borland C++/Delphi users have long had this ability.

http://www.codeguru.com/Cpp/V-S/devstudio_macros/versioncontrol/article.php/c3129

This solution makes use of Application_BeforeBuildStart() handler to increment the RC VERSIONINFO. The Build # is incremented even for failed builds.

http://www.codeproject.com/cpp/rcversion.asp

Not exactly an auto-increment solution. This allows you to enter the version info during the build process.

http://www.codeguru.com/Cpp/V-S/devstudio_macros/article.php/c3183

Another solution posted in CodeGuru. It is assignable to any key and when invoked it updates the RC “FileVersion” field and does “BuildToggleBuild”. :)

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q237870

Solution posted by MS. The autoincrementing code is attached to Application_BuildFinish(). It updates a #define in versionno.h which is included by the user resource file (RC2) .

http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-AutomaticBuildVersion&forum=totd&id=-1

I haven’t tried this. But, the author claims to combine the best of MS & Codeguru (second one) solutions.

I used a modified version of the solution from MS (mine didn’t update the RC; instead it updated a H file that was included across the project). If there is a neat/effective solution for this, let me know.

Some interesting links on 360 deg panorama pictures…


Do-It-Yourself : 360 degrees panorama
A lens attachment for taking 360deg pictures
Another lens attachment – Egg 360
And here is a review of iPIX 360 degree rotator