Tuesday, March 5, 2013

Repair Corrupted PDF File

I was looking for some tool to repair one of the PDF file but none helped. Some worked but they were licensed and didnt repair entirely.

Then I encountered Ghostscript which can repair corrupted PDF files automatically.

Ghostscript is a suite of software based on an interpreter for Adobe Systems' PostScript and Portable Document Format (PDF) page description languages. Its main purposes are the rasterization or rendering of such page description language files, for the display or printing of document pages, and the conversion between PostScript and PDF files.

Download URL:
Download and install Ghostscript from the location http://www.ghostscript.com/download/


How to Repair:
gswin32c.exe -o repairedfile.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress sourcefile.pdf

Password protected:
gswin32c.exe -o repairedfile.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -sPDFPassword=password sourcefile.pdf

gswin32c.exe is located in the installation directory and normally in C:\Program Files\gs\gs9.05\bin

Example:
C:\Program Files\gs\gs9.05\bin>gswin32c.exe -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress Vasantham.pdf

GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.

Processing pages 1 through 5.
Page 1
Page 2
Page 3
Page 4
Page 5

C:\Program Files\gs\gs9.05\bin>     Hope this helps !!

Friday, November 25, 2011

CruiseControl.NET Server Configuration (ccnet.config)

To configure the CruiseConrol.NET Server, the configuration file (ccnet.config) has to be configured and placed in the "server" folder which will be used by Cruise Control .NET for continuous integration. This sample file contains the settings for one of the test application created in Visual Studio. I have tried to configure all the possible settings which are used in practical situations.

This example uses Visual Source Safe (VSS) as the source control application which check for any modifications in VSS (IfModificationExists)  every 60 seconds.If any check-in happen in VSS, CruiseControl will pick get the latest files and prepare a auto build.

ccnet.config file

<cruisecontrol>
  <project name="CCTestApp" webURL="http://localhost/ccnet/server/local/project/CCTestApp/ViewProjectReport.aspx">
    <workingDirectory>C:\CruiseControlTest\BuildServer\CCTestApp</workingDirectory>
   <artifactDirectory>C:\CruiseControlTest\BuildServer\CCTestApp\Artifacts</artifactDirectory>
    <labeller type="defaultlabeller">
        <prefix>lblCCTestApp_build_</prefix>
        <incrementOnFailure>true</incrementOnFailure>
    </labeller>   
    <sourcecontrol type="vss" autoGetSource="true">
        <project>$/CCTestApp</project>
        <username>t799153</username>
        <password></password>
        <ssdir>C:\Chandreshwar\PROJ\DOTNET\VSS_DB\</ssdir>
       <workingDirectory>C:\CruiseControlTest\BuildServer\CCTestApp\Source</workingDirectory>
        <cleanCopy>true</cleanCopy>
        <applyLabel>false</applyLabel>
    </sourcecontrol>
    <triggers>
        <intervalTrigger seconds="60" buildCondition="IfModificationExists"/>
    </triggers>   
    <tasks>
        <devenv solutionfile="C:\CruiseControlTest\CCTest\CCTest.sln" configuration="release" executable="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"/>
        <modificationWriter>
             <filename>modifications.xml</filename>
             <path>C:\CruiseControlTest\BuildServer\CCTestApp</path>
        </modificationWriter>
    </tasks>
    <publishers>
      <xmllogger logDir="C:\CruiseControlTest\BuildServer\CCTestApp\BuildLogs" />
    </publishers>
  </project>
</cruisecontrol>


You can find the complete reference of all the configuration settings in CruiseControl.NET here.

Thursday, May 27, 2010

Quick Introduction to Scrum - An Agile Methodology

Its time for me to share the Agile approach of software development which we have applied to our projects since more than 6 months. Its the way I can remember what I worked on to be referenced in future instead of looking for material in my laptop or web community.

We have been using Scrum approach for software development and I really found very impressive with the shippable product at the end of each sprints. Believe me this approach really works which I was not able to assimilate before we planned to implement the process.

To answer what is Scrum, its an Agile approach to software development where project progresses in series of Iterations called Sprints. Each Sprint is usually 2-4 weeks with typically 5-9 members with following roles:
  • ScrumMaster - can be thought as a coach to help team to use Scrum and keep team members from any distractions. 
  • Product Owner - representing stake holders.
  • Team -  self-organized cross-functional team consisting of Programmers, Testers, Designers, Analysts.




Activities of Scrum:
Following are the main activities that are spanned throughout the iteration.

Sprint Planning Meeting -
This is the first activity for the iteration. Attendees for this meetings are product owner, scrum master, the team, business analysts, architects, database designers, etc.

First task in the planning meeting is to identify the resource availability during the period of sprint (e.g. of 10 days (2 weeks) of development/testing activity how many days each resource is available). Assuming all working at 50% productivity (distraction, un-predictable task), we arrive at total story point for the sprint (e.g. 6 resource available all 10 day comes to 60. Working at 50% productivity come to 30 story points). Story point can be thought as number of days and each story is estimated by story points rather than hours.

The product owner usually identifies the user stories before the start of planning meeting to reduce the time of discussion. Story can be thought as a brief feature description of work to be performed (e.g. multi funding enablement for reports) from the product backlog that need to be considered for the current iteration. Product owner along with Business Analysts explains all the stories well in detail to the team in order for them to estimate the tasks. Its not required that team members should come prepared for the meeting. They can ask all required questions till every one is very clear to estimate the tasks.

Estimation is done using "poker game" (cards with 1, 3, 5, 8, 13, 20, 40 points) where team, product owner, scrum master individually raises card to show how many point they feel for the story. Advantage of this is that all the members in the team estimate (cross team estimation) the stories which helps reveal any unknowns and assumptions. Estimate not only contains development tasks, but also involves designing, testing, deployment etc..

Upon completion of Planning Meeting, scrum master sticks the stories on the story board. Story board is any white board where is divided into 3 columns viz. Planned, Started and Done. From the image below, you can see that the each story is further broken down into tasks and put on post-its.




Daily Scrum Meeting -
Updating soon....

Sprint Review (Demo) -
Updating soon....

Sprint Retrospective -
Updating soon....

Sunday, March 28, 2010

Customize your Blogger blog with a novel look and feel

By this time you might have noticed the new layout of my blog with very unusual template as compared to out-of-the-box templates provided by Blogger.

You can now customize your Blogger Blog with new "Blogger in Draft". With new Template Designer introduced, you can customize look and layout of your blog to look dissimilar.

Go to http://draft.blogger.com/ and log-in using your Blogger account to use new templates as they are only available from here. Navigate to "Layout" and to the right, you will find "Template Designer" link to customize. (You wont find the "Template Designer" from www.blogger.com as this hasn't released yet)



Try now before they are released to all...


Official "Blogger in Draft": http://bloggerindraft.blogspot.com 

Friday, October 9, 2009

Search Text in all SQL Server Objects

Many time you come through a situation where you want to Search a text in SQL Objects such as table, stored procedure, views, triggers, etc.., but we don't get when required.

Below SQL Script will search any text assigned to @Search variable in all Tables, Users, Views, Functions, Stored Procedures, Primary Key, Foreign Key etc..


Script to search text in all SQL Server objects:

DECLARE @Search varchar(255)
SET @Search='xsp_get' -- GIVE YOUR SEARCH TEXT
SELECT DISTINCT
LEFT(so.name, 100) AS Object_Name,
LEFT(
CASE so.type
WHEN 'U' THEN 'Table - User'
WHEN 'S' THEN 'Table - System'
WHEN 'P' THEN 'Stored Procedure'

WHEN 'V' THEN 'Table - View'
WHEN 'TR' THEN 'Trigger'
WHEN 'C' THEN 'Constraint - Check'
WHEN 'D' THEN 'Default'
WHEN 'K' THEN 'Key - Primary'
WHEN 'F' THEN 'Key - Foreign'
WHEN 'L' THEN 'Log'
WHEN 'R' THEN 'Rule'
WHEN 'RF' THEN 'Replication Filter stp'
ELSE '<<UNKNOWN ' + so.type + '>>'
END
,25) AS Object_Type
FROM syscomments sc
INNER JOIN sysobjects so ON so.id = sc.id
WHERE text Like '%'+@Search+'%'
ORDER BY 2,1

Sunday, September 13, 2009

Facade Pattern with C#

Facade Pattern classified into Structural Pattern is unified interface that represents entire by hiding the complexities.

It provides the higher level interface which makes subsystem easier to use. It provides client with a single entry point which eliminates knowing the complexity of many subsystems beneath it.


In this pattern, facade object is aware of the responsibility owned by subsystem classes. It essentially delegates the client request to subsystem classes; whereas sub-system classes perform operation as assigned by facade object and doesn’t holds any reference to it.


Below is the sample class diagram demonstrates Facade pattern where client makes a call to Facade class and the subsystem operations are managed by facade thereby eliminating the client to directly deal with subsystems.




 
Code for Facade Class:

namespace MyProject.FacadePattern
{
public class Facade

{
private IValidateUser _validateuser;
private IAddUser _adduser;
private INotifyService _notifyservice;

public Facade()
{
_validateuser = new ValidateUser();
_adduser = new AddUser();
_notifyservice = new NotifyService();
}

public bool AddUser(User user)
{
if (!_validateuser.ValidateUser(user))
return false;

_adduser.AddUser(user);
_notifyservice.SendEmail(user);
}
}
}


< Back to Design Patterns

Thursday, September 10, 2009

Decorator Pattern with C#

Decorator Pattern classified into Structural Pattern which add responsibilities to objects dynamically.

A client application often needs to augment the services provided by methods of some class, by inserting some pre and post-processing tasks before and after the method calls. If distinct pre and post-processing tasks were to be carried out for different clients, the application logic would become complex by conditional statements, leading to a maintenance nightmare.

Consider a class where clients can invoke method to transfer files to and from some remote server. In addition to being able to upload and download files, the client application would also like to log all file transfer requests and perform access checks for each invocation.

An implementation based on the Decorator pattern would derive a class from FileTransfer and override the virtual methods, inserting the additional operations before and after calling the base methods. Client still continue to call the same method; however additional responsibility is added to the class without affecting other clients using the same functionality. Thus, Decorator Pattern allows dynamic and transparent addition and removal of responsibilities without affecting client code.

FileTransfer Class (used by multiple clients):
namespace MyProject.DecoratorPattern
{
public class FileTransfer
{
public virtual bool UploadFile(string url)
{
bool result;
// File Upload Logic
Console.WriteLine("File Uploaded to url :" + url);
result = true;
return result;
}

public virtual bool DownloadFile(string url, string localpath)
{
bool result;
// File Download Logic
Console.WriteLine("File downloaded to '{0}' from url '{1}'", url, localpath);
result = true;
return result;
}
}
}



Derive from FileTransfer Class:
namespace MyProject.DecoratorPattern
{
class Decorator : FileTransfer
{
//Additional Responsibility added without affecting client code, demonstrate Decorator Pattern.
public override bool UploadFile(string url)
{
bool result = false;
if (!AccessAllowed(url)) return result;
result = base.UploadFile(url);
LogActivity(url);
return result;
}
//Additional Responsibility added without affecting client code, demonstrate Decorator Pattern.
public override bool DownloadFile(string url, string localpath)
{
bool result = false;
if (!AccessAllowed(url)) return result;
result = base.DownloadFile(url, localpath);
LogActivity(url);
return result;
}
private bool AccessAllowed(string url)
{
bool result;
// URL access Logic
Console.WriteLine("Access Allowed to url :" + url);
result = true;
return result;
}
private void LogActivity(string url)
{
// Logic to Log Upload/Download Activity
Console.WriteLine("Activity logged for url: " + url);
}
}
}


< Back to Design Patterns