Sandip's Programming Zen

An attempt to share tech/coding experiences

SQLite Administrator: Great SQLite Windows client

leave a comment »

I have tried out few commercial and freeware SQLite client apps but none is better than SQLite Administrator, It’s simple and easy to use and all the core feature works flawlessly. I have used it couple of times before and this time I had simply forgotten the name and looked all over my PC to find out this program but since this is not an installable software (directly launched from exe) it’s difficult to locate because when you need it you simple download it and launch it from there and forget it thereafter. But this time I decided to write this post to make it searchable for me and of course others 😉

Written by Sandip

April 6, 2010 at 3:44 am

Posted in productivity, Softwares

Tagged with

Convert scanned pdf into image in C#

leave a comment »

I needed to convert scanned pdf into any image format so that I can run OCR operation for one of the DMS solutions I am working on. Actually I am using Tesseract (Open source OCR solution from Google) for OCR and it only takes image format as input. After spending few hours searching and trying few solution I zeroed in on this codeproject article which is making use of Ghostscript to achieve the core functionality.
So far this is the only solution I think works seamlessly on most windows platforms including Win7 (already tested on XP, Win2003, Win7).

Written by Sandip

March 23, 2010 at 7:16 am

Posted in .Net

Tagged with , , ,

C#: Accessing resources on network

leave a comment »

Accessing files and other resources on network from within code is achieved in following way in C# (of course there are other ways but this seems neat):

Take following assembly reference first:

using System.Runtime.InteropServices;

[DllImport(“advapi32.dll”, SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);

Private void YourFunction()

{

WindowsImpersonationContext wic;
IntPtr tokenHandle = new IntPtr(0);
bool returnValue = LogonUser(f.cUserName, f.cDomain, f.cPassword, 2, 0, ref tokenHandle);
WindowsIdentity ImpersonatedIdentity = new WindowsIdentity(tokenHandle);
WindowsImpersonationContext MyImpersonation = ImpersonatedIdentity.Impersonate();

wic = MyImpersonation;

// do some file IO activity here on server…

wic.Undo();

}

Written by Sandip

March 15, 2010 at 1:16 pm

Posted in .Net, Programming

Tagged with , ,

C# MP3 files organizer

leave a comment »

I have a huge collection of mp3 music files and locating music was bit difficult if I would like to hear a particular artist, I quickly tried to search on google , found some programs but unnecessarily complex, so I wrote my own , which is very simple.  it does following:

  • Asks for a target directory where your mp3 files are located.
  • On click of a button it extracts the meta info and organizes the files in folders per artist.

It’s very basic but useful to me at least. you are free to modify/use/distribute at your own risk 🙂

Download it from here.

Written by Sandip

March 15, 2010 at 1:07 pm

Posted in .Net, Programming

Tagged with ,

Retrieve compilation date of a .Net Assembly

leave a comment »

I wanted to display last update date on the application interface so users know when something is changed, mostly at the time of customer acceptance tests. I found following code from here. cool.

private DateTime DateCompiled()
{
    // The assembly version must have the last two numbers removed and replaced with *
    // It should look something like this: 
    // [assembly: AssemblyVersion("1.0.*")]
 
    //Build dates start from 01/01/2000
    System.DateTime result = DateTime.Parse("1/1/2000");
 
    //Retrieve the version information from the assembly from which this code is being executed
    System.Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
 
    //Add the number of days (build)
    result = result.AddDays(version.Build);
 
    //Add the number of seconds since midnight (revision) multiplied by 2
    result = result.AddSeconds(version.Revision * 2);
 
    //If we're currently in daylight saving time add an extra hour
    if (TimeZone.IsDaylightSavingTime(System.DateTime.Now, 
        TimeZone.CurrentTimeZone.GetDaylightChanges(System.DateTime.Now.Year))) 
    { 
        result = result.AddHours(1); 
    }
 
    return result;
}

Written by Sandip

February 16, 2010 at 11:11 am

Posted in .Net, Asp.Net, Programming

Tagged with ,

Notion Ink Adam Tablet

leave a comment »

This is the ideal table concept I would wish for. Amazing.

Written by Sandip

February 15, 2010 at 3:39 am

Posted in Science & Tech

Tagged with

Replacing “src” property using Javascript in embed tag

leave a comment »

Quickly,

If you try to replace the src property of embed tag using javascript , it will work fine in Firefox but not in IE.

To make it work in both you have to  wrap the embed tag in <div> and then replace the whole embed tag in div every time you want a change in src propert.

Written by Sandip

January 7, 2010 at 12:28 pm