Posts

Showing posts from 2009

Using gtalk with all IMs (except Skype)

How to... Skype does not support Jabber!

Drupal 6.x approx core DB/ER diagram

Image
Complete Drupal 6.x approx core Database Structure / Entity Relationship diagram All 46 of the core 6.x tables are included Overview: Detailed: Also, here's the Drupal Architecture Tier-Diagram:  

Drupal on XP and OSX Leopard

On XP Apache Enable mod_rewrite In Windows Enabling PHP in Mac OS X 10.5 Mysql on Mac Adding GD library for Mac OS X Leopard (Sheldon's tip) Admin for mysql - "award winning" Mac install send mail

Mac root passwd initialize from blank

Quickest fix "just do a 'sudo passwd root' and run through the passwd prompts to establish your new root password"

Mac menu shortcuts

Quickly find any menu item and launch it. (Mac OS 10.5) 1. Press Cmd-? FYI: That’s Cmd-Shift-/ 2. In the Help menu Search that opens, start typing a few letters of your desired menu command. 3. Arrow key down to the item you want and press Return to choose it.

USB modem eject

"There won't be any problem if you just eject the USB modem. Safe removal is generally necessary for data devices, because write operations are done in batch mode. Safe removal == write syncs before disconnect." Thanks Patil!

Mac Tips

Metamorphose-File-n-Folder-Renamer VNC Setup for connecting from XP (balt's tip)

Crossover cables for macs

These days u don't need crossover cables anywhere. The switches are intelligent, they change their mode. The mac ethernet port can detect if you are directly connecting to another machine and switch accordingly. So you can use a simple LAN cable.

Facebook valuation

Facebook stock trading open; valuation $6.5 billion "That's lower than the $10 billion valuation at which DST originally invested, as well as the $15 billion at which Microsoft invested $240 million in the fall of 2007. But those two figures are considered to be preferred-stock valuations, not paper valuations." Preferred-stocks are negotiated completely differently from the common and cannot be used to evaluate a company directly. Microsoft's preferred-stock purchase also included advertising rights . More info .

Covestors

Covestor Disrupts Wealth Management with New Multi-Managed Account

Recommended reading

1. The Intelligent Investor The 1970 edition preferred. 2. Common Stocks and Uncommon Profits and Other Writings All 3 Phil Fisher books in one. Though it looks radically different from #1 on the surface (about Growth stocks etc), the underlying principles are similar.

Lock-in for dividend reinvestment mutual funds as per section 80c

As you must've found out when trying to redeem your units after 3 years, the reinvestment plan leads to a recursive never-ending lock-in. You can never completely redeem your units. Descriptions and solutions here: 1 2

A comparison of a few mid range laptops

Mac MacPro Dell Studio XPS 13 ThinkPad T400 Winner Weight 2.13GHz Intel Core 2 Duo 2.26GHz Intel Core 2 Duo processor Intel(R) Core(TM) 2 Duo Processor P8600 (2.40GHz/ 1066 FSB/ 3MB Cache) Intel® Core™ 2 Duo Processor P8400 ( 2.26GHz 1GHz ) Dell 3 2GB of 1066MHz DDR3 memory 2GB of 1066MHz DDR3 memory 4GB (2 X 2GB) Dual Channel 1066MHz DDR3 SDRAM 2 GB DDR3 SDRAM 1066MHz Dell 3 160GB 5400-rpm hard drive 160GB 5400-rpm hard drive 320GB (7200 RPM) SATA Hard Drive 250GB Dell 3 NVIDIA GeForce 9400M graphics processor with 256MB of DDR2 SDRAM shared with main memory3 NVIDIA GeForce 9400M graphics processor with 256MB of DDR2 SDRAM shared with main memory3 Integrated NVIDIA® GeForce® 9400M graphics   MacPro 2 13.3-inch glossy widescreen display 13.3-inch LED-backlit glossy widescreen display Obsidian Black 13.3 " WXGA (1280x800) CCFL Display w/ 2MP webcam 14.1 " WXGA+ TFT with integrated came

No save as html option in 20087 mpp

Microsoft Office Project 2007 does not support the ability to save a project file as a Web page. Instead, you can save a project as a more flexible XML file. This enables you to apply any style sheet to the XML file.

Tax reforms initiated

[Thanks to Beyond Basics for the news] Direct Taxes Code Discussion New tax code: Pay 10% tax on Rs 10-lakh salary will ultimately replace the over four-decades old Income Tax Act and bring all other direct taxes like wealth tax under its purview Key proposals: Tax deduction limit on savings to be hiked to Rs 3 lakh (Rs 300,000) Income tax slabs proposed to be changed; highest tax rate of 30% for individuals to be applicable for income over Rs 25 lakh (Rs 2.5 million) Security transaction tax to be abolished Effective corporate tax rate at 25 % To scrap long, short-term capital gains distinction Business losses can be carried forward indefinitely No tax deduction on interest payable on any govt security Base year for calculation of cap gains tax moved to April 2000 Wealth tax liability to be discharged by payment of pre-paid taxes Income from certain transfers not be treated as capital gains Proposals for businesses: Taxation of all non profit organisations rationalised Profits of non

The Code Is The Design

Image
Why programming is about focus, and not hours of work or lines of code. Also, why you can't replace a racehorse with two cart horses. Most people don’t understand what a computer really is. It’s the modern equivalent of a magic wand. Its power is only limited by the person wielding it.   Jack Reeves From Slashdot The Code Is The Design "In 1992 C++ Journal published an essay by Jack W. Reeves called 'What Is Software Design?' Many credit this essay as being the first published instance of assertions such as 'programming is not about building software; programming is about designing software" From What is Software Design? o Real software is incredibly cheap to build, and getting cheaper all the time as computers get faster. o Real software is incredibly expensive to design. This is true because software is incredibly complex and because practically all the steps of a software project are part of the design process. o Programming is a design

dos reference disconnect network drive

net use * /delete Good command for deleting all network drives that might be slowing down your "My Computer"

nt clear network share passwords

rundll32.exe keymgr.dll, KRShowKeyMgr

2003 post - Recovery procedure for MySql passwords

1. Shutdown the MySQL Service. 2. Start mysqld with the option “—skip-grant-tables” 3. Set a new password using “shell> mysqladmin -u root password ‘mynewpassword’”

mpp 2007 protection password not working

"problem is that password is used only when it was set on first Save. IF you will save, then do save as it will not work." Basically, you can't set a password on an existing mpp file :) only on a new one.

2008-2009 SSE Composite (Shanghai Composite) Index comparison

Max Min Curr Max/Min Min/Min Curr/Min SP500 1557 666.79 954 2.335068 1 1.430735 SSE COMP 5900 1,664.93 3300 3.543693 1 1.982065 SENSEX 20800 7,697.39 14820 2.702215 1 1.925328

disable ms groove

under the 'Add/Remove Programs'

The Google Chrome OS

Introducing the Google Chrome OS a. An OS from Google b. A light, fast OS that simply works with and off the net with nothing stored locally Something we've all been waiting for. The from-scratch design and security seem to be good bonuses.

Static code analysis

About FxCop About Code Metrics Tips to interpret Code Metrics Maintainability Index (50 or more) Cyclomatic Complexity (keep less than 20) Depth of Inheritance (should not exceed 6) Class Coupling (threshold value more than 30 indicates potentially bad design) Stylecop

CheckForIllegalCrossThreadCalls

For accessing controls in a different thread from which they were created, set (static variable) TextBox.CheckForIllegalCrossThreadCalls = false; http://msdn.microsoft.com/en-us/library/system.windows.forms.control.checkforillegalcrossthreadcalls.aspx Without this, you will get the error “Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on” However, this is not a good idea for production code. http://discuss.joelonsoftware.com/default.asp?dotnet.12.460561.4 Please be warned

session state across apps

"For session state to be maintained across different web servers in the web farm, the Application Path of the website (For example \LM\W3SVC\2) in the IIS Metabase should be identical in all the web servers in the web farm. See KB 325056 for details." I guess that rules out sharing session between WIP and IOF, unless they can have the same virtual dirs (maybe on different servers in WST) ... ... we don't specify app name in the session state tag. It gets picked up automatically.

Storing large collections and tables

Some design considerations I would mention are 1. Storing a datatable or dataset anywhere is always a bad idea. These classes maintain history and a ton of additional data Best practice is to create a class for a unit of data and store a list of objects of that class If the query is a simple one or the data is large, querying the DB again is preferable to serializing/storing/deserializing in session/viewstate/cache. 2. showModalDialog has an option to pass arguments – even a collection – from the javascript itself. http://msdn.microsoft.com/en-us/library/ms536759(VS.85).aspx No need to ever store or come to the backend This can be used instead of querying the DB again 3. Viewstate is an even more dangerous place to store heavy objects than session The network is burdened with MBs of traffic and both the browser and server are burdened with creating and storing the object Viewstate is specifically for small page-specific data (like global variables required across postbacks) The only pl

Cannot delete folder

"Make sure the disk is not full or write-protected and that the file is not currently in use" Familiar? Here's an amazing little app for this long standing Windows annoyance.

ie8 dns cache clear

Basically IE8 was giving a "cannot display the webpage" for old sites and Outlook 2007 was down too. Firefox was working fine. IE8 seems to do some kind of DNS caching of its own and the only way out seems to be to "reset" advanced settings. Outlook 2007 seems to somehow depend on IE8 for connections too and once this was done, they both worked.

Long-term Capital Gains Tax India

Long-term Capital Gains Tax is charged if • Capital assets are held for more than three years and • In case of shares, securities listed on a recognized stock exchange in India, units of specified mutual funds, the period for holding is one year. Long-term capital gains are taxed at a basic rate of 20%. However, long-term capital gain from sale of equity shares or units of mutual funds are exempt from tax

Fixed Income Securities in India

A good link on Government Securities (G-Secs), Corporate Bonds and Debentures .

Dow vs SNP500

Year Avg Dow/Snp 2009 9.58 2008 9.25 2007 8.92 2006 8.71 2005 8.74 2000 7.52 1995 8.3 1990 8.01 1985 7.11 1980 7.52 1975 9.31 1970 9.07 1965 10.33 1960 11.06 1955 10.95 1950 11.76 Dow/Snp Min 6.86 Max 11.99

Multiplication tables with one loop/variable

// Multiplication tables int  n = 3; //Basic two loop code for  ( int  a = 1; a <= n; a++)      for  ( int  b = 1; b <= n; b++)          Console .WriteLine( "{0} x {1} = {2}" , a, b, a * b); //One loop variation for  ( int  a = 0; a < n * n; a++)      Console .WriteLine( "{0} x {1} = {2}" , (a / n) + 1, (a % n) + 1, ((a / n) + 1) * ((a % n) + 1));             

Fibonacci solutions :)

///  Impressive solution static   void  Main2( string [] args) {      int  t1 = 0, t2 = 0, i = 0, j = 1, count = 15;      Console .WriteLine(i);      Console .WriteLine(j);      for  ( int  a = 1; a < count; a++)     {          int  localval;          if  (a == 1)         {             t1 = i;             t2 = j;         }          else         {             localval = t1;             t1 = t2;             t2 = localval + t2;         }          if  (a == 1)              continue ;          Console .WriteLine(t2);     } } ///  Preferable solution :) static   void  Main( string [] args) {      int  i = 0, j = 1;      for  ( int  a = 1; a < 15; a++)     {          Console .WriteLine(i);         j += i;         i = j - i;     } }  

Treat Warnings as Errors

Tip: Treat Warnings as Errors Another neat day-one rule, along with DB sessions and ZERO error handling to ensure that your .Net code is as bug free as possible. The mantra during development has to be to break the app as much as possible, not supress errrors. Ban try-catch blocks! :) [update] The sooner you fall behind, the more time you will have to catch up "an informal slogan of the on-board shuttle group [that] captures the essence of keeping focused on the process" (Focus on breaking) "Gen-Xers sporting T-shirts and distracted looks, squeezing too much heroic code writing into too little time; rollerblades and mountain bikes tucked in corners; pizza boxes and Starbucks cups discarded in conference rooms... It's not the story of the on-board shuttle group" "How do they write the right stuff? The answer is, it's the process" "Software for Grown-Ups"

Control design and empty catch{} blocks

1. All code that is in the control should be reusable. Please don't put anything specific to your pages in the control For ex: Can gvTasks_RowDataBound, PopulateCaseGrid etc be reused by search too? 2. Three properties of _gvCases are already exposed as properties. If you need to do more manipulation of _gvCases in your pages, please expose the whole grid and remove these properties You can then directly work with the grid in your pages (this is not good design but it's better than putting custom code in the control) 3. Please avoid empty catch{} blocks at all costs! Like in gvTasks_RowDataBound This is the most common way to have the code ignore bugs and cause unpredictable, difficult-to-track behavior.

Web Forms Page Processing and Control Execution Lifecycle

I'm giving both a quick reference as well as the MSDN links to the full information here. Web Forms Page Processing ASP.NET Page Framework Initialization The page's Page_Init event is raised, and the page and control view state are restored. User Code Initialization The page's Page_Load event is raised. Validation The Validate method of any validator Web server controls is invoked to perform the control's specified validation. Event Handling If the page was called in response to a form event, the corresponding event handler in the page is called during this stage. Cleanup The Page_Unload event is called because the page has finished rendering and is ready to be discarded. Control Execution Lifecycle Initialize Load view state Process postback data Load Send postback change notifications Handle postback events Prerender Save state Render Dispose Unload

Abstract vs Sealed vs Static class

The main features of a static class are : They only contain static members. They cannot be instantiated. They are sealed. They cannot contain Instance Constructors. Basically: Static = Abstract + Sealed

Historical comparison of Sensex, Nifty and the S&P500

Yahoo provides data from 1997 for Sensex, from 2002 for Nifty and for 60 years or so for the S&P500 A simple averaging of historical closing day values of all 3 gives the following data: YearOfAvging Sensex/Snp Nifty/Snp Sensex/Nifty 2009 10.58 3.44 3.12 2008 11.50 3.64 3.23 2007 10.31 2.86 3.28 2006 8.22 2.35 3.15 2005 5.77 1.76 2.96 2004 4.69 1.49 2.90 2003 3.60 1.23 2.66 2002 3.42 1.12 2.91 2001 2.87 2000 3.15 1999 2.90 1998 2.73 1997 3.52 StdDev 3.18 0.93 0.19 Avg 5.64 2.24 3.03 StdDev/Avg 0.56 0.41 0.06 Some simple inferences from the above could be: 1. The ratio of Sensex/Nifty has changed little historically. Sensex is probably a little more optimistic and Nifty fluctuates about 15% less. 2. Sensex has gone from 2.7 times S&P500 to it's current almost 11 times. 3. Nifty has risen similarly, maybe about 1% less. On a related note: If you plot the S&P

.dbk file created by Sony Ericsson PC Suite

Problem: 1. View the contents of a .dbk file created by Sony Ericsson PC Suite 2. How do I open a dbk file? Solution: Rename the .dbk to .zip It will contain a bunch of plain text files, one of which has your contact list :)

gridview sorting without datasource

This is the first link any search on the topic yields: HOW TO: Using sorting / paging on GridView w/o a DataSourceControl DataSource For those of you scratching your heads wondering how he is able to pull the DataSource out of viewstate/thin air like that (a couple of people on that page seem to wonder too) The answer is seen in the full solution given by the same source He assigns to the DataSource in Page_Load :) In short, the way to page and sort a gridview is the same as what you've been doing for datagrids all these years if you're using your own data binding logic. I haven't yet seen a way to use GridView.SortDirection/SortExpression to do the job.

Failed to access IIS metabase

There is usually an error whenever you install IIS with .Net and try to run an ASP.net app the first time. And this error seems to change with every new version of .net and VS This seems to be the latest one. The fix has always been the same though C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_regiis -i

laptop disable touchpad on ibm r52

Or for any other laptop: The quickest way is to install the appropriate driver from synaptics . This will install a device manager giving you full control over all pointing devices on your laptop.

Win Zipfldr.dll Alternative

ZipfldrAlt Windows provides no direct way to use zipfldr.dll for zipping or unzipping from the command line. So I've written a wrapper around ICSharpCode.SharpZipLib.Zip And I've used ILMerge so the exe contains the SharpZipLib dll too. You can zip and unzip whole folders from the command line with it; no installation required. But I haven't coded it to accept individual file(s), only an entire folder.

Excel error - too many different cell formats

Most of the solutions on the web aren't helpful excelforum groups.google "including the possiblity that if you delete a format of a cell it really does not go away" Removing all formatting won't help you and support.microsoft tells you nothing The issue is that this error is actually misleading, it's not the cell formats but the styles that are too many. What you need to do is this Delete styles collection The code for the macro is duplicated here for posterity Option Explicit 'Deletes All Styles (Except Normal) From Active Workbook Sub ClearStyles() Dim i&, Cell As Range, RangeOfStyles As Range Application.ScreenUpdating = False Application.EnableEvents = False 'Add a temporary sheet Sheets.Add before:=Sheets(1) 'List all the styles For i = 1 To ActiveWorkbook.Styles.Count [a65536].End(xlUp).Offset(1, 0) = ActiveWorkbook. _ Styles(i).Name Next Set RangeOfStyles = Range(Columns(1).Rows(2), _

Some old 2008 financial crisis explanations

1. This one was one of the first after the initial mortgage crisis - When the bubble burst Duplicate link: The cost of financial ingenuity 2. A more recent and specific theory - Recipe for Disaster: The Formula That Killed Wall Street However, note one of the comments here which points out that a more appropriate title would be "the IMPROPER USE of this formula by less qualified I-bankers that destoryed Wall Street." The reason for highlighting this article though is the line on page-4: "But in the CDO market, people used the Gaussian copula model to convince themselves they didn't have any risk at all, when in fact they just didn't have any risk 99 percent of the time. The other 1 percent of the time they blew up. Those explosions may have been rare, but they could destroy all previous gains, and then some." 3. Unrelated but interesting - How Porsche hacked the financial system and made a killing

Rakesh Jhunjhunwala's portfolio (source:Outlook-Profit Feb-2009)

The two lists in the table below are unrelated but given together to save space. Some random low P/BV stocks (source:Again Outlook-Profit Feb-2009) RJ's stocks ashapura-minechem-ltd AGROTECH FOODS Ashok-Leyland-Ltd ALPHAGEO Balaji-Telefilms-Ltd aptech-ltd bharati-shipyard-ltd autoline-industries-ltd Birla-Corporation-Ltd BEML chennai-petroleum-corporation-ltd bhushan-steel-ltd deepak-fertilizers---petrochemicals-corp.-ltd BILCARE emco-ltd CRISIL Finolex-Cables-Ltd dwarikesh-sugar-industries-ltd gitanjali-gems-ltd Garware-Wall-Ropes-Ltd graphite-india-ltd GEOJIT FINANCE great-eastern-shipping-company-ltd GEOMETRIC SOFTWARE Gujarat-Fluorochemicals-Ltd HINDUSTAN OIL EXPLORATION gujarat-state-fertilizer---chemicals-ltd indage-vintners-ltd Inox-Leisure-Ltd infomedia-18-ltd J-K-Cement-Ltd ion-exchange-(india)-ltd Kirloskar-Ferrous-Industries-Ltd JB CHEMICALS AND PHARMA KLG-Systel-Ltd kajaria-ceramics-ltd kolte-patil-developers-lt

Wix installer API

http://sourceforge.net/projects/wix/ Pros a. The most comprehensive and customizable approach – used by MS extensively, to deploy Office 2007 etc b. Will give a seamless UI consistent with all Microsoft installations and a fully customizable look and feel – logos, backgrounds etc Cons c. Version 2.0 is stable and used by Microsoft but only works with VS2005 d. Version 3.0 is beta and works well with VS2008 but one of the core tools we need – heat.exe – lacks support and documentation since the developer left Microsoft :) But I can overcome this by writing the tool myself, it’s not very complicated. e. Wix in general, and version 3 in particular, are very poorly documented and implementation will definitely involve time – 2 weeks at a minimum. http://www.dalun.com/wix/default.htm covers calling InstallUtil.exe and how to Create a Website and Virtual Directory walkthrough http://www.codeproject.com/KB/install/WixTutorial2.aspx

TFS merge and branch

"Regarding code merging, we have created new folders/projects under 5.1.0.10 branch. These folders do not exist in the main XYZ2 branch. We are unable to do “merge” because merge is only if a file/folder is an offshoot of the branch. If you add these folders into the main branch manually, then connection between main branch and 5.1.0.10 branch is lost. Is there a way we can resolve this issue? Please let us know..." - In this case, you would have to do a “branch” from 5.1.0.10 to back XYZ2, not a merge. (You can specify the exact target location in XYZ2 while branching) That way, you will have a connection back to 5.1.0.10 from XYZ2. Merge is typically when you’re merging changes from one branch back to the trunk. Here, there is no trunk to merge with. - PS: This could possibly also be done to merge code across different branches of a trunk

Exchange/Outlook integration, Time Zones and conversions

Generic code to create all tasks at 0000 at the app server time zone Wherever the app is installed, it will use that Time Zone – IST, EST etc private static void setMeetingTimeZone(CalendarItemType result) { // from http://msdn.microsoft.com/en-us/library/bb738399.aspx result.MeetingTimeZone = new TimeZoneType(); result.MeetingTimeZone.TimeZoneName = TimeZoneInfo.Local.StandardName; } private void saveOccurences(int recurringMasterTaskId, List occurences) { foreach (CalendarItemType occurence in occurences) { TaskDALC.InsertTaskOccurence(recurringMasterTaskId, TimeZoneInfo.ConvertTimeFromUtc(occurence.Start, TimeZoneInfo.Local), TimeZoneInfo.ConvertTimeFromUtc(occurence.End, TimeZoneInfo.Local), occurence.ItemId.Id, occurence.ItemId.ChangeKey, "", ""); } } Outlook client could be anywhere and can send a date not in sync with Exchange. So instead of Item.Start we send the date as Item.StartUTC in the script (plus there was a client culture related fix too). Month(It

Inport 2009 Note

The 60+ posts showing a date of Feb 25 2009 were all imported here from a much older blog, but the dates were lost during the import process.

Outlook - attachment warnings and folder cleanups

'Press Alt-F11 and enter this first one in "ThisOutlookSession" to warn you whenever you write the word "attach" and forget to send an attachment 'If it doesn't work, reduce macro security to "medium" and restart Outlook Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim lngres As Long If InStr(1, UCase(Item.Body), "ATTACH") <> 0 Then If Item.Attachments.Count = 0 Then lngres = MsgBox("No attachment - send anyway?", _ vbYesNo + vbDefaultButton2 + vbQuestion, "No attachment") If lngres = vbNo Then Cancel = True End If End If End Sub 'This second one is trickier but more useful. It converts all mails in a folder to plain text and removes attachments. You have to add a rule to use it 'Enter this one in "ThisOutlookSession" too but add a rule to run when mails arrive and set it to run this script 'DO N

TFS issues raised and replies from MS

Q. Why does TFS Build require the 3.5 SDK even if it is building a 2.0 solution? Ans. Team Build uses MSBUILD in the background. When you installed Team Build 2008 it installs the 3.5 framework so when you run a build it using the 3.5 version of MSBUILD. This is hardcoded and cannot be changed. Q. A build server does not seem to be able to handle multiple builds on the same server since it causes workspaces to clash. It happens if you're trying to do 2 different builds on the same folders. It says one folder cannot belong to 2 workspaces. Is this because TFS uses file paths as absolute references to source safe paths once the workspace is created? Is there a workaround? Ans. Typically you queue your builds and the builds run one at a time sequentially so using the same workspace would never be a problem. You can run multiple build agents on the same computer, but doing so could cause problems like what you are seeing. When we do a build we lock down the build folder while doing th

DB, UI and MSI builds with TFS

I just finished an app called “C:\XYZ\Content Center\Database\ABC_Dev\DbBuilder” It’s a simple app that parses through a set of Build items (sql or project files) and builds them against a DB. The Build items, DB details and a few other things are configurable. For ex, for a normal / daily build: <add key="BuildItems" value="Scripts\ABC50_ChangeScript.sql,Scripts\ABC52_ChangeScript.sql,Scrip ts\ApABConfig.sql,Scripts\DeleteOnlyCode.sql,Views\Views.ssmssqlproj,Triggers\Triggers.ssm ssqlproj, Procedures\Procedures.ssmssqlproj,Functions\Functions.ssmssqlproj"/> (I’ve also fixed DeleteOnlyCode.sql above and included dropping views) More importantly, I’ve finished integrating it with the TFS build system (which took longer than the actual application). So we can fully automate our DB build now. I’ve still not included it though since right now our DB build will fail. Please let me know if we should fix the DB errors first or if I should go ahead and include it anyw

TFS multiple builds and build numbering

There were two problems in making a new automated build. 1. TFS requires a new build agent for every team project That means either installing 2 build services on Periyar or having a new build machine (Are we getting any value add out of having a separate team project for every branch?) 2. The same folder cannot be used as the workspace for more than one source control folder C:\XYZ can be used only for any one build The workarounds I did were 1. I am defining both the builds in the XYZProduct2 team project (I can point to any source control folder anyway) 2. There are now 3 virtual folders pointing to the same physical folder linkd C:\XYZ D:\Projects\Builds\Sources linkd D:\Projects\Builds\XYZProduct2 D:\Projects\Builds\Sources linkd D:\Projects\Builds\XYZProduct5.1.0.10 D:\Projects\Builds\Sources For every new build, we can make a new virtual folder and point it to D:\Projects\Builds\Sources C:\XYZ will always point to this folder anyway. So all builds happen in one folder with the s

Linkd

We are moving to a new folder structure where we will be using a virtual folder (specifically an “NTFS junction point”) called C:\XYZ instead of the old subst R: drive. The subst R: drive implementation had a lot of issues like no integration with IIS, VSTS2008, TFS Build etc Steps to change: 1. Please remove your existing R: drive “subst r: /D” 2. Remove any .bat file you have for creating the r: drive on startup 3. Install the Windows Server 2003 Resource Kit (even on XP) http://www.microsoft.com/downloads/details.aspx?FamilyID=9d467a69-57ff-4 ae7-96ee-b18c4790cffd&displaylang=en 4. Create the symbolic link (one time only, no bat file required) “linkd C:\XYZ E:\Projects\XYZ” 5. Delete your existing workspace and create a new one with "C:\XYZ" instead of R: as the root folder of your team project.

Migration process followed

Install SQL Analyzer Install TFS Install Team Explorer [Thursday] Lock VSS DB Incremental copy Unlock VSS DB Install VSS2005 Installed TFS plug-in for ABC_Dev.ssmssln Cleaned up VSS copy Unbound local ABCWebComplete.sln and JobServiceComplete.sln and bound to new VSS copy Change 2008 plug-in from TFS to VSS Converted ABCWebComplete.sln and JobServiceComplete.sln to 2008 , built and checked in [on a R51 laptop] Analyze VSS copy - ANALYZE -f -d -v1 "D:\VssBackup\data" Deleted beta folders from VSS (missed during cleanup) VSSConverter Analyze "D:\VssBackup\VSS2TeamFoundation\settings.xml" VSSConverter Migrate "D:\VssBackup\VSS2TeamFoundation\ migration_settings.xml" Labelled TFS [Friday] Fixed R: Fixed ABC50 (checked Linkd, Mountvol etc) Further cleaned up TFS Tried branch and merge of sample project Discarded SQL studio (Tried manual checkouts, manual edits, another trial etc. Process/plugin is buggy and not repeatable)

Useful links I found on TFS and VSS to TFS Migration

http://blogs.microsoft.co.il/blogs/srlteam/archive/2006/09/26/3367.aspx VSS to Team System Migration - complete Checklist http://blogs.msdn.com/team_foundation/archive/2005/02/23/379179.aspx Complete overview of Branching, Merging, and Shelving http://www.woodwardweb.com/vsts/000291.html (about Shelvesets) http://blogs.msdn.com/buckh/archive/2005/06/03/425125.aspx (CVS compared with TFS, note the atomic checkins) http://msdn2.microsoft.com/en-us/library/w6y8ezzs(VS.80).aspx (Shelve Command)

distinct on DataTable

2.0 feature DataView.ToTable Method (String, Boolean, String[])

DeleteOnlyCode.sql - SQL Server 2005

declare @procName varchar(500) declare cur cursor for select [name] from sys.objects where type = ‘p’ AND (NAME LIKE ‘USP_%’ OR NAME LIKE ‘cv_%’ ) open cur fetch next from cur into @procName while @@fetch_status = 0 begin exec(‘drop procedure ‘ + @procName) fetch next from cur into @procName end close cur deallocate cur declare @procName varchar(500) declare cur cursor for select [name] from sys.objects where type = ‘tr’ AND (NAME LIKE ‘trg_%’ ) open cur fetch next from cur into @procName while @@fetch_status = 0 begin exec(‘drop trigger ‘ + @procName) fetch next from cur into @procName end close cur deallocate cur declare @procName varchar(500) declare cur cursor for select [name] from sys.objects where (type = ‘fn’ or type = ‘if’ or type = ‘tf’) AND (NAME LIKE ‘ufn_%’ ) open cur fetch next from cur into @procName while @@fetch_status = 0 begin exec(‘drop function ‘ + @procName) fetch next from cur into @procName end close cur deallocate cur • Couldn’t find a definite way of different

ensureSecurity

It was this little bool that was causing the web to not be able to talk to the Service RemotingConfiguration.Configure(string filename, bool ensureSecurity); http://msdn2.microsoft.com/en-us/library/system.runtime.remoting.remotingconfiguration.configure.aspx Apparently, the 1.1 version of this method didn’t have that 2nd parameter. Also, we should probably ensure security later and actually pass the required authorization details to the service instead of disabling security.

Migrating to 2.0 aspnet

http://msdn2.microsoft.com/en-us/library/1d3t3c61.aspx "Under ASP.NET V1.1 persistent cookies do not time out, regardless of the setting of the timeout attribute. However, as of ASP.NET V2.0, persistent cookies do time out according to the timeout attribute." This and the fact that all the page_load bindings will have to be removed are the most important changes when migrating from 1.1 to 2.0 aspnet. HtmlForm.DefaultButton Property - new 2.0 feature http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.defaultbutton.aspx

2.0 aspnet_compiler

aspnet_compiler -v /Nwd -p “C:\iughuih\Visual Studio 2005\WebSites\NorthwindWebSite” “C:\kjhjkh\Visual Studio 2005\WebSites\NorthwindWebDeploy” (Then webshare to view with IIS - set to 2.0 if default is 1.1)

2.0 profile anonymousIdentification

<profile defaultProvider="AspNetSqlProfileProvider"> <providers> <clear/> <add name="AspNetSqlProfileProvider" connectionStringName="aspnetdbConnectionString2" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </providers> <properties> <add name="Favorites" type="FavBook" allowAnonymous="true" serializeAs="Binary" /> </properties> </profile> <anonymousIdentification enabled="true"/> </system.web>

2.0 securityTrimmingEnabled

<siteMap> <providers> <clear /> <add siteMapFile=”web.sitemap” name=”AspNetXmlSiteMapProvider” type=”System.Web.XmlSiteMapProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” securityTrimmingEnabled=”true” /> </providers> </siteMap>

2.0 aspnetdb

aspnet_regsql <add name=”aspnetdbConnectionString” connectionString=”Data Source=10.140.4.107;Initial Catalog=aspnetdb;Integrated Security=True” providerName=”System.Data.SqlClient” /> (System.Configuration.ConfigurationManager.ConnectionStrings[”aspnetdbConnectionString”].ConnectionString) <membership> <providers> <add name=”AspNetSqlMembershipProvider” type=”System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” connectionStringName=”aspnetdbConnectionString” enablePasswordRetrieval=”false” enablePasswordReset=”true” requiresQuestionAndAnswer=”true” applicationName=”/” requiresUniqueEmail=”false” passwordFormat=”Hashed” maxInvalidPasswordAttempts=”5” minRequiredPasswordLength=”7” minRequiredNonalphanumericCharacters=”1” passwordAttemptWindow=”10” passwordStrengthRegularExpression=”” /> </providers> </membership> <roleManager> <providers> <add name=”AspNetSqlRoleProvid

2.0 Enabling the database for SQL cache dependency (With windows auth)

C:\Program Files\Microsoft Visual Studio 8\VC>aspnet_regsql -S 10.140.4.107 -E -d Northwind -ed -t Customers -et <caching> <sqlCacheDependency enabled=”true” pollTime=”600”> <databases> <add name=”Northwind” connectionStringName=”NorthwindConnectionString”/> </databases> </sqlCacheDependency> </caching> </system.web> </configuration> <asp:SqlDataSource ID=”SqlDataSource1” runat=”server” CacheDuration=”120” ConnectionString=”<%$ ConnectionStrings:NorthwindConnectionString %>” EnableCaching=”True” SelectCommand=”SELECT * FROM [Customers]” SqlCacheDependency=”Northwind:Customers”></asp:SqlDataSource>

"Why use STATIC keyword with the main method"

“What will happen if the class doesn’t have a public constructor ?”

override vs new

1. override calls method of object new calls method of variable 2. “cannot override inherited member because it is not marked virtual, abstract, or override” new does not require “virtual, abstract, or override”

The Obsolete attribute

I was going to recommend using the Obsolete attribute for DefType.Refresh() We could even have done a [Obsolete(“Refresh not allowed for def types”, true)] so that the compiler issues an error and prints out a message. However, it won’t work since this particular case is a virtual/override method. ‘Obsolete’ is ignored for an overridden method. However, it should be useful in other cases. Just FYI

BindingFlags.Static | BindingFlags.Instance

The reason we were not able to access the private FieldInfo with NonPublic was that you have to specify if it is a Static field or not (an ‘Instance’ field) This combination will ensure that you get your field no matter what - BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance Console.WriteLine(T.GetField(“a”, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance).GetValue(x));

Disable zipped compressed folder support

http://www.tacktech.com/display.cfm?ttid=259 Solution: Click Start > Run... Type regsvr32 /u %windir%\system32\zipfldr.dll Click the OK button. To re-enable: Click Start > Run... Type regsvr32 %windir%\system32\zipfldr.dll Click the OK button.

Finding duplicate rows without a primary key

select a.CATEGORY_ID, a.CATEGORY_CD, a.TREE_NODE_NUM, a.PARENT_NODE_NAME from (select PARENT_NODE_NAME, TREE_NODE_NUM, CATEGORY_ID, CATEGORY_CD, rownum as num from ps_z_CAT_Tree_vw) a, (select PARENT_NODE_NAME, TREE_NODE_NUM, CATEGORY_ID, CATEGORY_CD, rownum as num from ps_z_CAT_Tree_vw) b where a.CATEGORY_ID = b.CATEGORY_ID and a.num<>b.num There’s no need to list both sets of fields because the union will cause both sets to be shown in different rows anyway.

Nhibernate session deserialized in another APP Domain

We have fixed the null key exception by adding this item in theÿ nhiberSQLServerSettings.config <add key=”hibernate.session_factory_name” value=”xxx_NHibernate_SQL_SessionFactory”/> The reason was when nhibernate session was deserialized in another APP Domain (another server), it was looking for the sameÿsession factory by the name. Earlier we were not setting this name property so a randomly generated GUID was assigned as the sessionÿfactoryÿname. Implications were that the name of the session factory was different in different app domains in different server. Hence session couldn’t find its factory and so couldn’t deserialize itself. Resolution is just to add this property in the config file.

SecurityException mscorlib.dll

As you know I changed my PC recently and on trying to run our nant scripts, I got this error “An unhandled exception of type ‘System.Security.SecurityException’ occurred in mscorlib.dll” And neither http://support.microsoft.com/kb/836989 (I already had SP1 and reinstalling didn’t help) Nor http://p2p.wrox.com/topic.asp?TOPIC_ID=3077 on that search worked for me. What finally worked was Control Panel Administrative Tools Microsoft .NET Framework 1.1 Wizards Adjust .Net security -> this comp -> local intranet=full trust

Run time primary keys for Datagrids

I believe a common problem we have faced in many of our screens is not having a primary key for the items in the datagrid. It sometimes becomes very difficult to differentiate between rows of the grids, especially in javascript and we have to use field combinations. Sometimes even that won’t work (if all fields are equal in two rows). Here’s an easy work around. What this does is generate an integral key for every row. You can use either the property that just-returns the key or increments-and-returns the key depending on whether you’re on the same row or moving to the next row. <asp:TemplateColumn HeaderText=”Authorized”> <ItemTemplate> <input type=”text” name=”Txt<%#IncLogSn%>” value=”<%#DataBinder.Eval(Container.DataItem,”Authorized”)%>”> <input type=”hidden” name=”Hid<%#LastLogSn%>” value=”<%#DataBinder.Eval(Container.DataItem,”Authorized”)%>”> </asp:TextBox> </ItemTemplate> </asp:TemplateColumn> private int LogSeria

Modifying datagrids without using DataGrid_ItemDataBound

A common requirement in most of our screens An advantage in the second case is that because you’re using a .Net literal control, the cell will maintain its value across post-backs You can code to specific conditions by varying the implementation of returnComparisonBool() <!-- For an image --> <asp:TemplateColumn HeaderText=”Physical Location” ItemStyle-HorizontalAlign=”Center” ItemStyle-VerticalAlign=”Middle”> <ItemTemplate> <a href=”#” onclick=’return launchAddrs(<%#DataBinder.Eval(Container.DataItem,”alt_id”)%>);’> <asp:Image ID=”Image1” Runat=”server” Visible=’<%#returnComparisonBool(DataBinder.Eval(Container.DataItem,”PHYS_LOC_CD”), “ALT”)%>’ ImageUrl=”../Images/VIEWB.bmp”> </asp:Image></a> </ItemTemplate> </asp:TemplateColumn> <!-- For an simple string --> <asp:TemplateColumn HeaderText=”Issued?” ItemStyle-HorizontalAlign=”Center” ItemStyle-VerticalAlign=”Middle”> <ItemTemplate> <asp:Literal Run

CacheItemPriority.NotRemovable

CacheItemPriority.NotRemovable - doesn’t make much difference -- Also, I found something that maybe useful “You can indirectly control the memory size of the cache by using the memoryLimit attribute in in machine.config. The cache engine will start throwing items out of the cache agressively when that memory limit is getting close.” I’ll try reducing that and testing on my PC Also, see this Apparently, things can get thrown out even if “NotRemovable” Which is strange because apparently even “inProc session” uses NotRemovable cache internally Another thing is We’re using DateTime.MaxValue for absoluteExpiration ideally, we should use NoAbsoluteExpiration But internally they are the same But I’ll try reducing the memory and see Cache.NoAbsoluteExpiration “When used, this field sets the absoluteExpiration parameter equal to MaxValue, which is a constant representing “ Same thing, actually... We do this Cache.Insert(index, _CacheKeys, null, DateTime.MaxValue, Ideally, it should be Cache.

Response.Redirect or End

We have a new issue as a result of moving the NHiberSession to HttpSessionState. In short, whenever a Response.Redirect or a Response.End is called, the Global_ReleaseRequestState is bypassed. Instead, a ThreadAbortException is raised (as you may know) and then Application_EndRequest is raised directly. This is normal. In our case though, before Application_EndRequest, a SerializationException exception is raised because our NHiberSession is still connected. NHiberSession cannot be serialized when connected and it can only be disconnected in Global_ReleaseRequestState since we need the session for it. I tried to store the NHiberSession (a similar sample object) in System.Web.HttpRuntime.Cache and disconnect it in Application_EndRequest but as you can infer from the above, the Session has already been unsuccessfully serialized by then and this has no effect. Yes, specifying the second parameter as false solves the Response.Redirect problem. In fact, this is supposed to be the correct wa

Too many cookies?

”We’re setting too many cookies and so losing the session.” Number and size limits of a cookie in Internet Explorer At least 300 cookies At least 4096 bytes per cookie (as measured by the size of the characters that comprise the cookie non-terminal in the syntax description of the Set-Cookie header) At least 20 cookies per unique host or domain name (Also, see the limits for Netscape ) Basically, our application stored various little values in a cookie and when those values exceeded 20, the user got logged off.

C# constant arrays

As you must know, there’s no such thing as C# constant arrays - http://www.google.com/search?hl=en&q=c%23+const+array For example, the below code will not compile const int [] constIntArray = newint [] {2, 3, 4}; On the other hand, a static readonly will compile static readonly int [] constIntArray = new int[] {1, 2, 3}; But it’s of no use since even though cannot reassign the array itself, you can replace individual values. The readonly makes you think it cannot be changed, which is bad because you could end up wrong values at runtime. What I needed was an array that I couldn’t re-assign at run time. As usual, I was trying to avoid hard-coding something and in this case it was field names. I needed some way to work with field names so that even if the names or the order of the fields changed tomorrow, I could just change an enum and the constants and the rest of the code would work fine. Of course, I could simply do this public enum Fields { ItemId = 0, ShortDescription =

Archive

Show more