Wednesday, December 16, 2009

Vakati's IE Saver - To Save content from all open Webpages

There are times when I want to restart the computer but not close all the opened internet explorer sessions as I might want to view them later.This simple application writtten in vb.net can be used to save you from the afore mentioned scenario.IE Saver can not only save all the open links and restore them back with a click of button but also can store all the open pages content to a folder that can be viewed later offline with out a connection to the internet.Here is the link for it.

Monday, December 14, 2009

Simple UI to Maintain Subversion (SVN) Authorization File

I really enjoyed the installation,configuration and using of Subversion as an alternate to Source Safe.SVN is really fast reliable scalable and TortoiseSVN can be used as a client to interact SVN server.

Configuring SVN is fairly easily especially with packages like visualsvn server,collabnet svn and many more.As you all might know in Subversion(SVN) granualar permissions on the projects can be done using a authorization file.Authorization file can be set using AuthzSVNAccessFile(svn-auth.conf) directive in httpd.conf file.You can create groups, add users to the groups, add groups and users to the projects in the authorization file.

I wrote this small and simple application to Manage/Maintain Users,Groups,Project Assignments in the authorization file using .net.I know this is not going to save a lot of time for all but it is handy at times, so I did it.Here is the link for it.



**This program is not tested properly hence you are responsible for testing and then using it on your production systems.Feedback is always welcome.

A Simple Attendance System - .net c# access

One time I had to create a small attendance system for a not-for-profit organization, even though this is a simple application it might be handy to use.Will be able to add your child/employee/equipment/shipping or any other things you want to track daily and mark their presence.

You can run daily and monthly reports.This application is written in c# and access 2003.

Here is the link to download the application binaries.

Feedback welcome.

Monday, December 7, 2009

Microsoft Treeview Nodes.AddRange

Have you ever tried to add nodes in the Microsoft Treeview using the AddRange method, it is not fun to do that as you cannot create a new TreeNodeCollection.After doing quite a bit of research we found a way to do this.Here is the trick.

vb.net sample code:

Dim ndc as new list(of TreeNode)

For i as Integer = 0 to 10 step 1
Dim nd as new TreeNode
nd.text = "node " + i.tostring
ndc.add(nd)
Next 1

Me.treeview1.Nodes.AddRange(ndc.ToArray)

Sunday, October 25, 2009

AVIC z1 Installation Toyota Celica GTS

Here are the installation instructions of the AVIC z1 on a Toyota Celica 2001 gts.Before going into that I have to tell I love my AVIC Z1 double din navigation system with cd/mp3/dvd player with a rear view camera and bluetooth adapter.

I am not a electronic or mechanical geek by any means,but still I want it to be done.So I did some decent amount of home work before I started working on it.I had to thank newcelica.org for all the instructions on how to take things apart and Toyota for all the plastic clips that are used for fastening the interior to the car.Last but not the last I have to really thank Poineer team for compiling such a simple installation manual.It is here

I started with installing the rear view camera,I installed the camera in the key hole of my celica.Took the plastic thing below the hatch and then removed the three bolts to take the plastic thing above the license plate that hold the keyhole.Passed the wire to the through the holes in the hatch to the roof and then connected the voilet/white(rear input signal) to the reverse light bulb postive wire in the trunk by removing the plastic cover that hides the tail lights in the trunk.This wire is also passed to the roof through inside plastic cover next to the rear seat.

After that I decide to install the GPS Antenna on the top of the car near the point where the roof and hatch meets, I would have hidden it somewhere but the installation manual says that it is better to install the antenna on a flat surface and is outside the car.I passed the gps antenna to the roof with the rear view camera wire.

Sunday, May 24, 2009

Crystal Reports Run Time - Visual Studio AnyCPU Target

Following error is raised when you run a report on a 64 bit machine with 32 bit Crystal Reports Run Time.

---------------------------Crystal Reports---------------------------

An error has occurred while attempting to load the Crystal Reports runtime.
Either the Crystal Reports registry key permissions are insufficient or the Crystal Reports runtime is not installed correctly.Please install the appropriate Crystal Reports redistributable (CRRedist*.msi) containing the correct version of the Crystal Reports runtime (x86, x64, or Itanium) required. Please go to http://www.businessobjects.com/support for more information.

After targetting the solution to x86 instead of AnyCpu,report loaded OK.

Crystal Reports - Fake Login Dialog

We have Crystal Reports in our application and noticed a fake Login Dialog that doesn't do anything even when credentials are supplied.After doing some research we found that sql native client is missing.

Saturday, February 28, 2009

SVN Upgrade from 1.4.5 - 1.5.5 (Apache 2.0.63 - 2.2.8)

For every person there are three basic things that are needed to survive,clothing,food and shelter.But as a software developer there is a fourth one that is needed to live.SVN is what I am talking about.

About 9 months ago we migrated from Visual Source Safe to Subversion, using Subversion is easy and a nice experience.

At the time of install, they had Subversion 1.4.5 and Apache Web Server 2.0.63.This week Subversion released a new version 1.5.5 and it seems some of the nice features are added to this version,so we want to do the upgrade.

In the old versions we were using multiple sources of authentication,domain based and file based.As we had some contracters outside the company it really worked out very well.

I uninstalled the old version of Apache and Subversion and installed new version using the collabnet subversion.

During the upgrade everything really went well except our multiple sources of authentication part.It seems that authauthoritative in mod_auth is removed from the new version of Apache.(after 2.2.x).So this made it impossible to use our domain based and file based authentication.

If you are using Apache Web Server 2.2 and above you will notice that authauthoritative Off or ON in the http.conf wont start the apache.

mod_auth_dbm can be used in the place of mod_auth for file based authentication.

Sample Domain Based and File based authentication.(Versions earlier than 2.2)


DAV svn

#For network shares - notice the forward SLASHES
#SVNPath "//TestServer/TestRepo/"
SVNPath E:\SvnRepos
# SSLRequireSSL
# SVNIndexXSLT "/htdocs/svnindex.xsl"
AuthName "Enter username and password"
AuthzSVNAccessFile "C:\Program Files\Apache Group\Apache2\conf\svn-auth.conf"

AuthType SSPI
SSPIAuth On
SSPIAuthoritative On
SSPIDomain pme.local
SSPIOfferBasic on
SSPIOmitDomain On

# Htpasswd Logins.
AuthType Basic
AuthAuthoritative Off
AuthUserFile "C:\Program Files\Apache Group\Apache2\conf\passwd"
require valid-user

Wednesday, February 4, 2009

Regular Expression for Decimal Scientific and Fraction Values : ALL IN ONE

Regular expressions are really handy when user input needs to be validated.The following expression can be used to validate Decimal or Fraction or Scientific values.

^(([+-]?([0-9]*\d*\.\d{1}?\d*))(\-?(?:((\d+\s*)?\d+\/[1-9]+[0-9]*)(\d+(\s*\d+\/[1-9]+[0-9]*)?)))(^[+-]?[0-9]*(?:\.\d?)?[Ee][-+]?\d+))$

The big list of matches and non-matches below is the hard work of one of my colleagues.

Matches
0 ,0.0 ,-0 ,-0.0 ,+0 ,+0.0 ,0.1 ,-0.1 ,+0.1 ,1 ,1.1 ,-1 ,-1.1 ,+1 ,+1.1 ,1.1234567890 ,-1.1234567890 ,1.12345678901234567890 ,-1.12345678901234567890 ,0E0 ,-0E0 ,+0E0 ,
1E2 ,1E+2 ,1E-2 ,-1E2 ,-1E+2 ,-1E-2 ,+1E2 ,+1E+2 ,+1E-2 ,1.E+2 ,1.E-2 ,1.0E+2 ,1.0E-2 ,
.0E+2 ,-.0E+2 ,+.0E+2 ,.1E+2 ,-.1E+2 ,+.1E+2 ,12345678901234567890E+2 ,1.0e+2 ,0/1 ,
-0/1 ,1/1 ,-1/1 ,1 0/1 ,1 1/1 ,-1 1/1 ,0 1/1 ,-0 1/1 ,1/8 ,-1/8 ,1 1/8 ,-1 1/8 ,10/8 ,12345/12346

Non-Matches
. ,&5 ,1,2 ,1d5 ,-1- ,-1.-1 ,+1+ ,+1.1+ ,E ,.E ,E0 ,0E ,-E0 ,-0E ,+E0 ,+0E ,1E++2 ,1E+-2 ,1E+2- ,
1E+2+ ,1E-+2 ,1E--2 ,1E-2- ,1E-2+ ,1E+.2 ,1E+2. ,1E+2.0 ,1.E+.2 ,1.E+2. ,.E+2 ,-.E+2 ,+.E+2 ,
.-E+2 ,.+E+2 ,-.E+2 ,1+E+2 ,1-E+2 ,1.+E+2 ,1.0+E+2 ,0/0 ,1/0 ,1 0/0 ,1 1/0 ,0 0/0 ,1-/8 ,1/-8 ,
1/+8 ,1/8- ,1-1/8 ,1 -1/8 ,-1- 1/8 ,+1+1/8 ,+1 +1/8 ,+1 1+/8 ,+1 1/+8 ,1E/8 ,1E2/8 ,1./8 ,1.2/8 ,
.5/8 ,5/.8 ,1.5 1/8 ,.1 1/8

Saturday, January 31, 2009

a small t-sql puzzle

A friend of mine found a small sql puzzle online somewhere and told me about that.I know it is not that hard to solve the problem using t-sql but I want to find out all the possible ways that I can to solve the puzzle.

Two tables
1.Users with their color assignments
2.All the possible colors.

Problem:
Find all the people that has all the colors in the second table.

Solutions:

Declare @usrs table(
[name] varchar(5),
Color varchar(10)
)
Declare @AllColors table(
Color varchar(10)
)
insert into @usrs values('a','red')
insert into @usrs values('a','green')
insert into @usrs values('a','blue')
insert into @usrs values('b','red')
insert into @usrs values('b','green')
insert into @usrs values('c','blue')
insert into @usrs values('c','red')
insert into @usrs values('c','green')
insert into @usrs values('d','blue')
insert into @usrs values('d','red')
insert into @usrs values('e','green')
insert into @usrs values('e','blue')


insert into @allColors values('red')
insert into @allColors values('green')
insert into @allColors values('blue')
--Solution1
Declare @AllColorsString Varchar(Max)
Select @AllColorsString = isnull(@AllColorsString,'')+ Color +','
From @AllColors
Order by Color ;
Print @AllColorsString;
With usrsNColors as
(
SELECT u1.name,
( SELECT Color + ','
FROM @usrs u2
WHERE u2.name = u1.name
ORDER BY color
FOR XML PATH('') ) AS ColorsAssigned
FROM @usrs u1
GROUP BY [name]
)
Select [Name],ColorsAssigned
From usrsNColors
Where ColorsAssigned = @AllColorsString;

--Solution2
SELECT DISTINCT Name, Colors
FROM @usrs u1
CROSS APPLY ( SELECT Color + ','
FROM @usrs u2
WHERE u2.Name = u1.Name
ORDER BY Color
FOR XML PATH('') ) D ( Colors )
Where Colors = @AllColorsString;
--Solution3
WITH CTE ( [name], colorList, ctecolor, length )
AS ( SELECT name, CAST( '' AS VARCHAR(8000) ), CAST( '' AS VARCHAR(8000) ), 0
FROM @usrs
GROUP BY [name]
UNION ALL
SELECT p.[name], CAST( colorList +
CASE WHEN length = 0 THEN '' ELSE ', ' END + color AS VARCHAR(8000) ),
CAST( color AS VARCHAR(8000)), length + 1
FROM CTE c
INNER JOIN @usrs p
ON c.name = p.name
WHERE p.color> c.ctecolor )
select [name],colorList from cte
where length = (select count(*) from @AllColors)
Order by [name];

--Solution 4 (very similar to 3)
WITH CTE ( [name], colorList, ctecolor, length )
AS ( SELECT name, CAST( '' AS VARCHAR(100) ), CAST( '' AS VARCHAR(100) ), 0
FROM @usrs
GROUP BY [name]
UNION ALL
SELECT p.[name], CAST( colorList +
CASE WHEN length = 0 THEN '' ELSE ',' END + color AS VARCHAR(100) ),
CAST( color AS VARCHAR(100)), length + 1
FROM CTE c
INNER JOIN @usrs p
ON c.name = p.name
WHERE p.color> c.ctecolor )
select [name],colorList from cte
where colorList+',' = @AllColorsString
Order by [name];

--Solution5
With usrsNColors as
(
select row_number() over (partition by Name order by Color asc) as rownum, Name,Color
from @usrs
)
,ColorCntForUsr AS
(
Select Name,Max(rownum) as TotalColors From usrsNColors
Group By Name
)
Select * from ColorCntForUsr
Where TotalColors = (Select Count(*) from @AllColors);

--Solution6
select Name, Sum(case when a.color = u.color then 1 else 0 end) as matchCount from @usrs u
cross Join @AllColors a
Group by Name
Having Sum(case when a.color = u.color then 1 else 0 end) = (Select Count(*) from @AllColors);

--Solution7
Very similar to 6 but with a Inner Join.

Friday, January 30, 2009

OSQL - Running all the SQL Scripts in a given folder

Like I said in my earlier post OSQL is very useful to run sql scripts and run queries.This post demonstrates the use of OSQL in running all the scripts in a given folder.

@ECHO OFF
:: Keep variables local

SETLOCAL
:: Check command line arguments
SET Server=%1
SET Database=%2
SET Test=%3

IF NOT DEFINED Server
GOTO Syntax

IF NOT DEFINED Database GOTO Syntax

IF DEFINED Test GOTO Syntax

:: Execute sql scriptsFOR %%f IN (*.sql)
DO
(
:: ECHO Running script %%f... ECHO ^>^> %%f
OSQL -E -S %1 -d %2 -n -m-1 -b -i "%%f"
IF ERRORLEVEL 1
( ECHO.
ECHO ^>^> Critcal error in script %%f! Ending execution.
GOTO End
)
)
:: Display complete message
ECHO.
ECHO Finished running sql scripts on database %2

:: Done
GOTO End

:Syntax
ECHO.
ECHO Usage: RunSQLScripts server database scriptpath
GOTO End

:End
ENDLOCAL

OSQL - Running Queries in a Batch File

OSQL is another very useful tool I and my group use very often.We used it to execute all the sql files in a folder against a given server and database.

Here is the batch file I use to check if all the user procedures and user defined functions in a database has a execute persmission for a user ROLE called 'APPUSER'.

This sample batch file also demonstrates how to execute sql queries using OSQL in a batch file.


@ECHO OFF
:: Keep variables local
SETLOCAL

SET Query="select so.name from sys.objects so LEFT OUTER JOIN sys.database_permissions p on so.[object_id] = p.major_id inner JOIN sys.database_principals dp on dp.name = 'APPUSER' where so.Type IN ('P') and p.major_id is null"

ECHO ^>^> Running CheckIfAPPUSERIsGrantedExecuteOnAllProcs
ECHO ^>^> ----------------------------------------------
:serverset server=
set /P server=^>^> Enter Server Name or Type exit to Exit: %=%

if "%server%"=="" goto serverif "%server%"=="exit"
goto End

:databaseset database=
set /P database=^>^> Enter Database Name or Type exit to Exit: %=%
if "%database%"=="" goto databaseif "%database%"=="exit"
goto End

:: Execute sql scripts
ECHO ^>^> Checking . . . Please Wait!
OSQL -E -S %1 -d %2 -n -m-1 -b -Q %Query%

IF ERRORLEVEL 1
(
ECHO ^>^> Critcal error while checking Database %2,Ending Checking.
GOTO End
)

:: Display complete message
ECHO Check Complete on database %2
:: Done
GOTO End

:End
ENDLOCAL
pause
exit

IIS Manager Crashes on Load/Start Windows 7, IIS 7.5

IIS Manager Crashes on Start  Windows 7, IIS 7.5, Power Shell 5.1. Here is the error I got in the event viewer. IISMANAGER_CRASH IIS Ma...