- first select the emails you want to delete
- then mark them as spam
- in in the span folder swipe the email to the right to delete it forever
Monday, 31 December 2012
How to delete gmail from android app
Friday, 28 December 2012
Javascript framework performance tester
http://jsperf.com/angular-vs-knockout-vs-ember/2
Also this is quite a good reference for all the difference frameworks that are out there at the moment to choose from
http://addyosmani.github.com/todomvc/
Performance test results for various browsers as follows...
IE 8.0 32-bit on Windows 7 64-bit
Chrome IE 9 32-bit on Windows 7 64-bit
Chrome 23.0.1271.97 32-bit on Windows 7 64-bit
Thursday, 13 December 2012
How to use the Translator Generator VS 2010 Extension
Installation
- Ensure you have the following installed...
a)http://www.microsoft.com/en-us/download/details.aspx?id=21835
b)http://visualstudiogallery.msdn.microsoft.com/25e4b5e9-65e4-4950-967d-5f1e6a9dcbeb/?lc=1033 - simply double click the downloaded vsix file - Install the TranslatorGenerator VSIX package by double clicking on it. You will see the following window appear, just click the Install button.
- If you have successfully installed you will see the following message...
Enabling the Translator Generator
- Open your solution in visual studio 2010
- Enable the translator generator from Tools, Guidance Package Manager, Enable / Disable Packages..., check Translator Generator option, OK
Using the Translator Generator
- Open a new Visual Studio instance after installing the package
- Right click on your target project and select Create Translator from the Translator Generator context menu option
- Click the ... buttons to choose your first and second classes, which are your source and target entities that you wish to create translator logic for
- Then click the Next button
- Now click the Map All button, this will attempt to match up similar named properties (case insensitive, and underscore characters ignored)
- You can then select properties manually in each side and click the map button to line these up as well
- Then click the finish button. Your newly created translator will end up under the Translators folder in your project.
Uninstalling
- Run the following command from a VS.NET command prompt window
VSIXInstaller.exe /U:8E53EB18-6A5C-4068-B24F-DE7147F3BB3E
- You should then see this window
- Then restart visual studio to ensure the package is completely removed from your extensions folder which is under
%userprofile%\AppData\Local\Microsoft\VisualStudio\10.0\Extensions
Monday, 3 December 2012
How to clear the Windows 7 Print Spooler
http://support.microsoft.com/kb/946737 – Method D
Run the following commands in order from a command prompt. I just stick them in a batch file called fixprint.bat under the %windir% windows folder.
net stop spooler
del %systemroot%\system32\spool\printers\*.shd
del %systemroot%\system32\spool\printers\*.spl
net start spooler
Configuring SQL Server Service Broker
Found a good step by step article here on SQL server central
http://www.sqlservercentral.com/articles/Service+Broker/67513/
At a high level these are the points to remember
To configure the service broker to send and receive messages between databases (either in local/remote instances), it needs few components in place to start the service. These are listed below.
- Enable the Service Broker on the database
- Create valid Message Types.
- Create a Contract for the conversation.
- Create Queues for the Communication.
- Create Services for the Communication.
Monday, 19 November 2012
No files were found to look in
If Visual Studio returns the message "No Files Were found to look in" from the find in files results window, then just do a Ctrl+Alt+PauseBreak key press withing the find results window, and search again.
How to fix the DELL 968 All in one printer, scanner
I came across this issue myself this weekend,
http://en.community.dell.com/support-forums/peripherals/f/3528/p/19298625/20231966.aspx#20231966
Issue
"When trying to scan from printer direct or via all-in-one centre the printer starts the scan and then shuts down/re-starts? Any ideas/seen this before? Thanks Steve"
Solution:
Spent ages searching the web for a solution for this one, but in the end the old "2 - inch drop" was all it really needed...
Just took the two screws out of the left of the flat bed scanner glass section. Then removed the left hand grey panel that snaps in place to the left of these screws on the side of the printer. Then managed to get enough leeway out of the flat bed scanner glass holder, to reach in and give the scanner bar inside a bit of a shake.
Switched off and on again, and the scanner bar reset itself to the correct location, which is, when working correctly, out of site underneath the A4 indicator bar.
Thursday, 15 November 2012
Deep clone of an object by rewinding the Serialization stream
/// <summary>
/// Serializes this class to a json string.
/// </summary>
/// <returns>A JSON string reprsenting a SelectListItem.</returns>
public string ToJson()
{
using (var memoryStream = new MemoryStream())
{
var dataContractJsonSerializer = new DataContractJsonSerializer(typeof(JsonSerializableSelectListItem));
dataContractJsonSerializer.WriteObject(memoryStream, this);
memoryStream.Position = 0;
using (var streamReader = new StreamReader(memoryStream))
{
return streamReader.ReadToEnd();
}
}
}
Wednesday, 14 November 2012
How to Tune Up a Virtual PC
If your VPC seems slow try the following steps to rectify.
1. Have separate drives for your Page File, Host operating system, and VHD file
2.Try defragging again using O&O defrag (http://www.oo-software.com/home/en/products/oodefrag/) instead of the standard windows defrag tool, it works better. The steps below may take some time but should dramatically improve the responsiveness of your VPC. Make sure you have at least as much free space on your drive where the .vhd file is located as the current size of the .vhd. For example, if your .vhd file is 8GB, you need 8GB+ of free space. This much free space is not necessary but will speed up the defrag process. At the very least, try to have a couple gigs of free space before running defrag.
Warning: If you run these steps on a differencing or undo disk, compacting will require you to merge the differencing or undo disk with the original. If you cannot do this, your differencing or undo disk will be twice the size. However, it will most likely still perform better.
Note: Running defrag and precompacting are done inside the VPC. Compacting the disk is done using the Virtual PC Console with the VPC turned off.
Running Defrag (about 30 to 90 minutes depending on how fragmented the drive is)
1. Download the defrag utility and extract the defrag.exe and defragps.dll files to a location on the VPC root drive.
2. Inside the VPC, click Start, and then Run. Type cmd and press ENTER.
3. Change the path to the location where you extracted the defrag.exe and defragps.dll files , i.e. cd c:\tools\defrag and press ENTER.
4. Type defrag -d c: and press ENTER.
5. Let this process go for awhile. At the end your .vhd file will be about twice the size.
Next, you must precompact inside the VPC before compacting the .vhd.
Running Precompact (about 10 minutes)
1. On the VPC menu click CD, then Capture ISO Image.
2. Browse to C:\Program Files\Microsoft Virtual PC\Virtual Machine Additions\
3. Double-click Virtual Machine Precompactor.iso
4. If it doesn't launch, open the D drive in Explorer and double-click precompact.exe.
5. Let this process run. When it's done, shut down the VPC.
Now you can compact the .vhd file using the Virtual PC Console
Compacting the .vhd file (about 30 minutes)
1. Go to the Virtual PC Console, select your VPC, and then click Settings.
2. Select Hard Disk 1.
3. Click Virtual Disk Wizard.
4. Click Next on the first screen of the wizard.
5. Click Edit an existing virtual disk, and then click Next.
6. Click Browse on the Virtual Disk to Edit screen of the wizard and browse to your .vhd file. Select it and click Open.
7. Click Next.
8. Click Compact it (this should be the default), and then click Next.
9. Click Replacing the original file, and then click Next.
10. Click Finish. The disk compacting will start.
Other Performance Tips
- Disable all visual enhancements
1. Right-click My Computer, and then click Properties.
2. On the Advanced tab click the Settings button in the Performance section.
3. On the Visual Effects tab, click Custom then uncheck everything in the list below.
4. Click OK.
- Turn off automatic updates
- Set hardware acceleration to full
1. Right-click the desktop, and then click Properties.
2. On the Settings tab click Advanced.
3. On the Troubleshoot tab, move the Hardware acceleration slider to Full.
4. Click OK
- If you have an old spare 20GB drive lying around, you can use that as an external USB drive and dedicate the entire partition to a single VPC. This will have good performance even with undo disk on as there is virtually little or no fragmentation even over prolonged usage.
- Hard disk paging is bad. Make sure that you balance memory allocation for both the VPC and the Host machine. Allocating too much memory to the VPC can cause your host machine to page to the hard disk and vice versa. With 2GB memory on the host machine, you can allocate 1GB to the VPC with good performance (even with Outlook 2007 and the IE browser running).
- Try the Windows registry optimization with your host machine and VPCs.
- Disable paging of the OS core files (look for the registry keyDisablePagingExecutive inHKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management and set the value to 0x1)
- Disable the updating of the last access timestamp on the file system (run fsutil behavior set disablelastaccess 1 from the command prompt).
- Reboot. Note the first registry tip is only useful if you have sufficient memory allocated to avoid hard disk paging.
- To improve performance for applications in the VPC (applies to Windows Servers 2003)
- Right click on Computer and select Properties.
- Select the Advanced tab.
- In the Performance section, click on Settings.
- Under the Advanced tab, select best performance for Programs instead ofBackground services. For windows 2003 servers, this is normally set toBackground services.
- Reboot.
- If you have a Core Duo or Core 2 Duo processor on your machine, it should have support for hardware virtualization support. Make sure to do the following:
- Turn on the Virtual Machine Monitor (VMM) in the bios settings. Depending on the bios type, there may be one or two settings related to this. Make sure all are enabled. If you do not see the settings in the bios, it means your hardware manufacturer has not implemented the support.
- Enable Hardware Virtualization support in VirtualPC 2007. In the Virtual PC Console, go to File menu and select Options.
- Under every VPC's settings, you should then be able to set the Hardware Virtualization option. This is only grayed out if you haven't done the previous two steps or if you don't have the right processor.
- In the virtual machine, make sure that you have installed the latest VirtualPC 2007 Virtual Additions if you have not done so.
WCF System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly
WCF System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly
If you get the above error when trying to return large numbers of items in a List<T> from a WCF service, then ensure you have set the following behaviour for the dataContractSerializer in both your client and service configuration files..
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
As in this blog, but with larger number (i.e. max of int)http://processmentor.com/community/blogs/scott_middleton/archive/2007/06/08/169.aspx
Need the settings in service layer and client, set to this.
Service has this
<behavior name="MyService.ServiceImplementation.MyService_Behavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
<dataContractSerializer maxItemsInObjectGraph="2147483646"/>
</behavior>
</serviceBehaviors>
<service behaviorConfiguration="MyService.ServiceImplementation.MyService_Behavior"
name="MyService.ServiceImplementation.MyService">
<endpoint binding="basicHttpBinding"bindingConfiguration="BasicHttpBinding_Leads"
bindingNamespace="http://MyService.ServiceContracts/2007/04"
contract="MyService.ServiceContracts.IMyService" />
<endpoint address="mex" binding="mexHttpBinding"contract="IMetadataExchange" />
</service>
</services>
Client has this …
<behaviors>
<endpointBehaviors>
<behavior name="debuggingBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483646" />
</behavior>
</endpointBehaviors>
</behaviors>
<endpoint address="http://localhost/Host/Internal/myservice.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMyService"contract="LeadsServiceInternal.IMyService" name="BasicHttpBinding_IMyService"
behaviorConfiguration="debuggingBehaviour"
/>
Note you must also set the following two settings on the client maxReceivedMessageSize and maxBufferSize
<binding name="BasicHttpBinding_IMyService" closeTimeout="00:01:00" openTimeout="00:01:00"receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"maxBufferSize="500000000" maxBufferPoolSize="524288" maxReceivedMessageSize="500000000"messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192"maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<security mode="None">
<transport clientCredentialType="None"proxyCredentialType="None" realm=""/>
<message clientCredentialType="UserName"algorithmSuite="Default"/>
</security>
</binding>
Tuesday, 6 November 2012
How to remove the encryption from Humax HDR Fox T2 HiDef recordings
http://hummy.tv/forum/threads/black-holes-trail-guide-to-hdr-fox-t2-hacking.354/
Keep watching this post to see how I get on.
So far so good, following these steps
Use FTP to access the Humax file system*
Pull the .hmt file (from the file set that comprises an HiDef recording) onto my PC (using FTP)
Use the Foxy utility to clear the ENC (Encrypted) flag in the .hmt file
Send the .hmt back to the Humax
Copy the HiDef recording to the USB stick decrypted (because the ENC flag was cleared)
Move it to the PC and do something with it
*Settings.. System.. Internet Setting.. FTP Server.. ON
Name: Humax (or whatever you like)
FTP Server: 192.168.1.64 (or whatever your IP address is)
FTP Port: 21 (default)
User ID: humaxftp
Password: 0000 (unless you've changed it)
Passive Mode: NO (very important)
Save Password: YES
Mask Password: YES (doesn't matter)
Anonymous Login: NO
Got Foxy from here...
http://dc356.4shared.com/download/ImQij8V5/foxy.zip?tsid=20121106-223151-d7dcfcfe
Further updates:
The ftp copy to NTFS didn't work,
but then I discovered this post which I'm resting all hopes on now...
Samsung AllShare Software = File transfer no encryption! -http://hummy.tv/forum/threads/samsung-allshare-software-file-transfer-no-encryption.2449/
All share can be downloaded here - http://www.samsung.com/global/allshare/pcsw/download/AllSharePCSW.exe - Note to get round the hotfix loop in the installer, Right click this exe and select run as administrator. Actually you may have to run the install twice, as it appears to get stuck in the hotfix loop the first time you run it. Use Task manager to end the install process, and then run it again using run as administrator option. Then RESTART YOUR COMPUTER!!!
Main software page for it here - http://www.samsung.com/global/allshare/pcsw/
Important Note: In order to get Samsung All Share to see your Humax box, then on the Humax box you must enable content share, under the Internet settings menu option for the box.
Final update:
Now just waiting to see if the full 8gb comes down via the all share interface..... BOOM! It worked.
SQL to drop and recreate foreign keys
SELECT 'To' 'Direction',
OBJECT_NAME(sfk.constraint_object_id) 'ConstraintName',
OBJECT_NAME(parent_object_id) 'ConstrainedTable',
psc.name 'ConstrainedColumn',
OBJECT_NAME(referenced_object_id) 'ConstrainingTable',
csc.name 'ConstraingColumn',
'ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' + QUOTENAME(OBJECT_NAME(parent_object_id)) + ' WITH NOCHECK ADD CONSTRAINT ' + QUOTENAME(OBJECT_NAME(sfk.constraint_object_id)) + ' FOREIGN KEY(['+psc.name + ']) REFERENCES ' + OBJECT_NAME(referenced_object_id) +' ([' + csc.name +'])' AS [CreateScript] ,
'ALTER TABLE ' + QUOTENAME(OBJECT_SCHEMA_NAME(parent_object_id)) + '.' + QUOTENAME(OBJECT_NAME(parent_object_id)) + ' DROP CONSTRAINT ' + QUOTENAME(OBJECT_NAME(sfk.constraint_object_id)) AS [DropScript]
FROM sys.foreign_key_columns sfk
INNER JOIN sys.columns psc ON psc.column_id = sfk.parent_column_id
AND sfk.parent_object_id = psc.object_id
INNER JOIN sys.columns csc ON csc.column_id = sfk.referenced_column_id
AND sfk.referenced_object_id = csc.object_id
WHERE OBJECT_NAME(sfk.constraint_object_id) IN
(
SELECT CONSTRAINT_NAME
FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C
)
Thursday, 1 November 2012
How to replace the battery in a Jag X-Type Key Fob, and reprogramming the key fob
NOTE: MAKE SURE YOU DO THIS SOON AFTER THE BATTERY DIES ON YOUR KEY FOB. IF YOU LEAVE IT TOO LONG THE MEMORY ON THE CHIP WILL BE WIPED, AND JUST REPLACING THE BATTERY IN THE KEY FOB WONT BE ENOUGH!!!
See the reprogramming information further down this page for the solution for reprogramming the key fob should this happen.
Replacing the battery
Here is just a quick write-up on how to replace the battery in the key fob. The only tool you need is a small flat head screwdriver.First you can use the small flat head in this small tab to pull the fob into two pieces.
It should look like this after getting it apart.
Then taking the part with the buttons on it you will see a spot to use the flat head to start to work your way around to make that come apart into 2 pieces.
Once that's in two pieces you will see a small screw on the circuit board in the top left corner in the pic. The small flat head will allow you to unscrew this.
Then you will be able to pull the circuit board out and will allow you access to the battery.
Now you just use the flat head again to help pull the battery out and replace. Note: At this step I also used a cotton bud doused in some alcohol (Rum as there was some in the cupboard) to clean the contacts on the circuit board.
Once the new battery is in its just a matter of screwing the circuit board back in and everything else will just click back together. Now you have a fresh battery. You shouldn't have to reprogram the key fob it should just start working again if the battery was dead so just click the buttons to test. However if the battery has been dead a long while you will most likely have to reprogram the key fob.
Hope this helps some people out.
Reprogramming the key fob
Action:To program the remote transmitter(s) without using Worldwide Diagnostic System (WDS), follow the procedure outlined below.
Note: When carrying out the alarm remote programming, ensure that
no other vehicles within a 50 meter radius are undergoing the same
programming procedure, as this could affect the programming
operation.
Note: All required remote transmitters must be available when carrying out this procedure.
1. Open driver's door using the metal part of the key.
2. Turn the ignition switch to the 'auxiliary' position, then turn the ignition switch to the 'ON' position and back to the 'auxiliary' position four times quickly (about one turn each half a second).
Note: A chime from the Generic Electronic Module (GEM) will indicate
programming status has been enabled.
3. Turn the ignition switch to 'OFF' position.
4. Remove the key from the ignition switch.
5. To program the transmitter, press any key within 10 seconds.
Note: If the remote transmitter has been accepted, the GEM will
make a chime.
6. If any other remote transmitters are to be programmed, press any button once on each transmitter within 10 seconds.
Note: A maximum of four remote transmitters can be programmed to the vehicle at any one time.
7. Close driver door.
Wednesday, 31 October 2012
Beware the perils of Javascript
These two links are definitely worth a read I think...
http://oreilly.com/javascript/excerpts/javascript-good-parts/bad-parts.html
and especially…
http://oreilly.com/javascript/excerpts/javascript-good-parts/awful-parts.html
e.g.
Semicolon Insertion
JavaScript has a mechanism that tries to correct faulty programs by automatically inserting semicolons. Do not depend on this. It can mask more serious errors.
It sometimes inserts semicolons in places where they are not welcome. Consider the consequences of semicolon insertion on thereturn statement. If a return statement returns a value, that value expression must begin on the same line as the return:
{
status: true
};
This appears to return an object containing a status member. Unfortunately, semicolon insertion turns it into a statement that returns undefined. There is no warning that semicolon insertion caused the misinterpretation of the program. The problem can be avoided if the { is placed at the end of the previous line and not at the beginning of the next line:
status: true
};
Tuesday, 30 October 2012
TSQL Performance Tuning
Below is an example of the TSQL you can use to investigate your stored procedure's performance. Best to put this in a snippet if you're using VS 2012 or greater versions of SQL Management Studio I find.
SET NOCOUNT ON
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS
CHECKPOINT
GO
PRINT ' '
PRINT '-- START: ProcName --------------------------------------------------------------------------------------------------------------------------------'
PRINT ' '
SET STATISTICS IO ON
SET STATISTICS TIME ON
EXEC dbo.MyProcNameHere
SET STATISTICS TIME OFF
SET STATISTICS IO OFF
PRINT ' '
PRINT '-- END: ProcName --------------------------------------------------------------------------------------------------------------------------------'
PRINT ' '
GO
Monday, 29 October 2012
Windows 8 - Keyboard Shortcuts
Those of you that know me, will know I'm pretty much obsessed with keyboard shortcuts. So imagine my delight when I came across this new list today whilst reading this review of Windows 8:
Windows logo key + start typing: Search your PC
Ctrl+plus (+) or Ctrl+minus (-): Zoom in or out of many items, like apps pinned to the Start screen or in the Store
Ctrl+scroll wheel: Zoom in or out of many items, like apps pinned to the Start screen or in the Store
Windows logo key + C: Open the charms
Windows logo key + F: Open the Search charm
Windows logo key +H: Open the Share charm
Windows logo key +I: Open the Settings charm
Windows logo key + K: Open the Devices charm
Windows logo key + O: Lock the screen orientation (portrait or landscape)
Windows logo key + Z: Open commands for the app
Windows logo key + PgUp: Move the Start screen and apps to the monitor on the right (apps in the desktop won’t change monitors)
Windows logo key + PgDn: Move the Start screen and apps to the monitor on the left (apps in the desktop won’t change monitors)
Windows logo key + Shift+period (.): Snap an app to the left
Windows logo key + period (.): Snap an app to the right
Monday, 22 October 2012
YSlow CSS inspector
Just installed the YSlow browser extension for Chrome (although versions are available for other browsers too!).
http://developer.yahoo.com/yslow/
Not bad for finding where things on your site can be improved…
Design patterns
Other than the usual gang of four articles, http://www.dofactory.com/Patterns/Patterns.aspx, today I chanced across this page whilst reading the asp.net mvc best practices wiki, which had some more sample code for design-patterns....
Friday, 28 September 2012
How to create the DataContracts and Translators for Entity Framework generated objects
Think I've just come up with a fool proof method for creating datacontracts and associated translator logic from Entity Framework generated objects
Creating datacontracts
1. Grab the class definition from the xxxModel.cs file in xxxx.DataContracts.csproj project
2. Paste into a new file in the xxx.DataContracts namespace
3. Use Resharper to clean up the code (Ctrl +E , Ctrl + C), choose full format option
4. Suspend off Resharper (Tools, options ,Resharper)
5. Grab the primitives section and change privates to publics
6. Replace ; with { get; set; } and then replace _ with empty string
7. That's it, you now have your matching datacontract with no typos and property names matching the auto generated ones in the xxxModel.cs file.
Creating translators (little bit more involved) method
1. Use the following regex replace expression on the pasted properties from the class you created above.
Remember to paste them from the datatype definition onwards, and put them at the start of the line in the mapping class first! e.g.
String Author { get; set; }
String DMlibraryName { get; set; }
DateTime? DateCreated { get; set; }
String DocNAME { get; set; }
int? DocNumber { get; set; }
String DocPath { get; set; }
String DocTypeCode { get; set; }
String DocTypeDescription { get; set; }
Int32 IsDMType { get; set; }
Int32 IsRRAKMANType { get; set; }
int? PersonID { get; set; }
int? ProjectID { get; set; }
String ProjectLabel { get; set; }
String htmlLocation { get; set; }
Find: ^([a-zA-Z_$][a-zA-Z0-9_$?]*):b{(.*)}\{(.*)
Replace with: source.\1 = dest.\1;
Result is as follows...
source.Author = document.Author;
source.DMlibraryName = document.DMlibraryName;
source.DateCreated = document.DateCreated;
source.DocNAME = document.DocNAME;
source.DocNumber = document.DocNumber;
source.DocPath = document.DocPath;
source.DocTypeCode = document.DocTypeCode;
source.DocTypeDescription = document.DocTypeDescription;
source.IsDMType = document.IsDMType;
source.IsRRAKMANType = document.IsRRAKMANType;
source.PersonID = document.PersonID;
source.ProjectID = document.ProjectID;
source.ProjectLabel = document.ProjectLabel;
source.htmlLocation = document.htmlLocation;
(Old Creating translators (little bit more involved) method)
1. Turn resharper back on
2. Use the File Structure window
3. Stick this in Excel and do some manipulation (ask me if you're not sure how to do this)
4. Paste this back into your C# file, and do a regex replace of \t with nothing
5. That's it, translator code written
How to determine if a process is running in a DOS batch file
Trick is to use tasklist.exe and pipe the output through a find then check the errorlevel as follows...
tasklist /FI "IMAGENAME eq WebDev.WebServer40.exe" 2>NUL | find /I /N "WebDev.WebServer40.exe">NUL
if "%ERRORLEVEL%"=="0" GOTO START
echo. Starting web app dev server
call sw.bat
:START
Wednesday, 26 September 2012
JavaScript dates are zero based for month part
It appears that JS treats dates as zero indexed on the month part when you construct them in the format new Date("yyyy", "MM", "dd")
Friday, 14 September 2012
DataContract attribute gotcha
A little known fact that has caught out a few of our project team members this week, including myself. If you annotate a class with the DataContract attribute, then you must also ensure that the members you want to have serialized are also annotated with the DataMember / EnumMember attribute as well. The ones that aren't annotated will NOT get de-serialized when the data arrives at the consumer of your service method.
Note: If you apply no DataContract annotation at all to the class, then this has the same affect of attributing every member in your class with the DataMember / EnumMember attribute.
To be fair, this is somewhat eluded to in the following Microsoft article, although the part about it being implicit if you don't apply the attribute is not entirely obvious at first...
Silverlight 5 also supports a simplified opt-out model for serialization, where these attributes can be omitted from the type and the members of the type to be serialized. The data contract is implicit in the sense that the visibility modifiers (public, private) used by the type determines whether it and its members are included in the data contract. In this model, the name of a member is used to identify it in the serialized representation. A new IgnoreDataMemberAttribute attribute can be used to opt-out a member that is public when required.
How to put a 3 second wait in a batch file
ping -n 3 localhost >nul
Killing Visual Studio quickly
Stick this in a batch file in your %systemroot%, then you can run it from anywhere
tskill devenv
REM 3 second wait for the macro question to come up
ping -n 3 localhost >nul
tskill vsaenv10
tskill vsmsvr10
Thursday, 13 September 2012
Visual Studio 2010 breakpoint ordering
In case any of you use the breakpoint window for setting bookmarks in code as well, then this will be very useful to you in VS2010, if you were used to VS2008, just putting the latest break point at the end of the list like I was...
Wednesday, 15 August 2012
How to send large files around the web
There are many ways to do this, using http://yousendit.com for example, but the best that I have come across to date is definitely https://www.wetransfer.com/
This requires no registration / login process, and you can send up to 2gb at a time, with no limit on the amount of times you can do this.
Thursday, 9 August 2012
How to get MSN messenger to work again
Follow these steps again to get windows live messenger working again when one of your contacts has switched to the new outlook.com or hotmail.co.uk domain.
Start, Run..., tsKill msnmsgr
Then log on via Hotmail.com on the web and sign into web messenger, then delete all references to your friend from your Hotmail messenger contacts, then enter this in your hosts file
Start, run… , notepad %systemroot%\system32\drivers\etc\hosts
Enter this…
127.0.0.1 messenger.hotmail.com
Then delete this folder here
C:\Users\MyUserName\AppData\Local\Microsoft\Windows Live\Contacts
Then restart msnmgr.exe - C:\Program Files (x86)\Windows Live\Messenger\msnmsgr.exe
Now add back your friend that you removed from your contacts using their new sign in address
10 classic mistakes that plague software development projects
Excellent article just pointed out to me by one of my colleagues at work today...
I have copied the article here below, just in case it ever gets removed from that site...
By Justin James
April 20, 2012, 4:01 PM PDT
Takeaway: When you combine project management pitfalls with software development challenges, you have a recipe for some big (but often preventable) problems.
Project management is never an exact science, but when you combine it with the vagaries of software development, you have a recipe for disaster. I have seen a fair number of common mistakes that project managers make when working with software development projects. Some of these mistakes are not exclusive to software development, but they are especially prevalent and damaging in that context.
1: The “pregnant woman” mistake
Fred Brooks illustrated a common project management mistake with his famous statement that just because one woman can have a baby in nine months does not mean that nine women can have a baby in one month. And we still see this come up time and time again — the idea that throwing more people at a problem can make it be fixed quicker. Sadly, this is just not true.
Every person you add to a project adds friction to the project as well – things like the time needed to bring them up to speed or coordinate their work with other people. In fact, my experience has been that there is a tipping point where adding people actually slows the work down more than it speeds things up, especially for the first few months. And there are many tasks that just can’t be split up to be done by many people or teams at once. They simply have to be done “one foot in front of the other.”
2: The wrong metrics
Managers need metrics for variety of reasons: measuring “success” or status, performance reviews and analysis, and so on. The mistake I see too often is that the easier it is to collect a metric, the more likely that it’s not measuring anything useful. Of course, the easiest metrics to collect or understand are also the most likely to be used. Let’s take “bug tickets” as an example.
It is easy to count how many tickets get entered. But that is not a good measure of quality, because how many of those tickets are user error or truly “features”? So managers often look to the next level of metric: ticket resolution rate (tickets closed per day or week or iteration or whatever). If you have ever dealt with a help desk that constantly closes tickets for things that aren’t actually fixed, causing a proliferation of tickets, you know what it’s like dealing with an organization driven by this metric!
Instead of actually getting work done or helping the user (for example, leaving tickets open until the user accepts the resolution), the organization exists solely to open as many tickets as possible and then close them as quickly as possible, so it can get its resolution rate up. A better number would be the hardest to measure: ratio of true “bug tickets” created in relationship to features deployed, changes made, or something similar. Needless to say, that is not an easy number to understand or to collect and report on. The result is that organizations choose to make decisions based on the wrong metrics rather than the right ones, due to convenience.
3: Estimating times too far out
A common problem I see with certain project management methodologies is that they like to play “just so stories” with timelines and time estimates. Project manager who honestly think they know what pieces of functionality any given developer will be working on more than a month or two out (unless it is a very large, broad piece of functionality) are likely to be disappointed and mistaken. Software development is just too unpredictable. Even if you can prevent or account for all the usual things that alter timelines and priorities, there is still little guarantee that things will take the time you think they will.
4: Estimating times too broadly
Another typical issue with time estimates involves not breaking tasks down into small enough pieces. If I’m told that a piece of work will take one week, I’ll ask where exactly that number is coming from. Unless someone has analysed all the minor pieces of work in the whole, a “one-week” time estimate is nothing but pure conjecture and should be disregarded.
5: Failing to account for tasks
How many times have you seen a deadline blown because it was established without accounting for a critical task like testing? That is another reason why you cannot and should not ever accept a task on a timeline that is not broken down into its component tasks. There is a chance that the estimate omits something important.
6: Poor communications
It is important to keep everyone in the loop on project status, but it is easy to forget to do it. This is where a lot of the mistrust between IT and the business team comes from: The business does not feel like it has a good handle on what’s happening with its projects. And the more it feels left in the dark, the more likely it is to start trying to micromanage or force things to happen the way it feels it should be done. You can mitigate this problem by letting people know where things stand, both on a regular basis and when milestones are accomplished or the status changes.
7: Disconnected business priorities
There is often a wide gap between the priorities of projects within the development organization, the priority of the project in the view of the overall business, and the priority of the project in the eyes of the requester. A common issue is that a “high priority” project for one department is not viewed as important by the business because it does not generate revenues, and so the developers also downgrade it. Everyone needs to be on the same page with priorities, and a large part of that is to ensure that business units are not evaluated on the basis of projects that the overall business considers lower priority.
8: Constructing a wall of process
When the development team feels overwhelmed, one of the natural reactions is to establish a lot of process to slow things down. I have worked at places where even the most simple of changes required a change request form to be filled out (on paper, of course), in triplicate, physically disseminated, agreed upon, cross-signed by managers, and after all of that, there was still a 45-day minimum time until the work was to be done! Needless to say, this organization was not seen as a “partner” or an “important lever for getting work done” in the business, they were seen as a cost center and treated as such. The wall of process is typically a stopgap measure to deal with deeper issues in the process or company’s culture, and while it is easier to put up the wall than to deal with those issues (and in some companies, the issues are irreconcilable), the wall of process is counterproductive and leads to a hostile environment.
9: The “hit-the-ground-running” myth
When adding people to a project, it is tempting to assume that they can hit the ground running. No one hits the ground running in the world of software development, and those who say they do are mistaken. Every project has an acclimation period, and the farther along the project is, the longer that acclimation period is — there is more and more code to understand and get a handle on. Failing to take this into account will get you into hot water. It may take only a few days or weeks for a developer to come into the project at the beginning, but it could take months for a developer to be fully productive when added to the project long after it has started
10: Multi-tasking
This is another “skill” (like “hitting the ground running”) that people think they have, but they really do not. The more you ask people to multi-task, the worse their work will be and the longer it will take. This applies to multi-tasking at the minute-to-minute level (juggling emails, phone calls, actual work, etc.) as well as the hour-to-hour or day-to-day level (handling multiple projects). The more you demand from people, the more the wheels fall off. To make it even worse, multi-tasking not only is likely to mangle the work, but it grinds people up and sends them looking for another job eventually… forcing you to bring in new people in the middle of a project and causing even more issues.
Wednesday, 25 July 2012
Team foundation server power tools
Had completely forgotten about these handy little tools that helps you figure out what your team members are up to in source control…
http://msdn.microsoft.com/en-us/vstudio/bb980963.aspx
This one, http://visualstudiogallery.msdn.microsoft.com/c255a1e4-04ba-4f68-8f4e-cd473d6b971f, for example allows you to see your team members in team explorer, and run queries against them. Didn't even realise there was a status search built into source control until I found this option this morning.
Tuesday, 24 July 2012
Fix for Icons in WPF being blurry
Just found this article on stack overflow about why our WPF icons appear blurry.
http://stackoverflow.com/questions/5645274/image-in-wpf-getting-blurry
Turns out you can fix this by adding the following attached properties to your images
<Image Source="/LoginPanel;component/Icons/icoLogin.ico"
RenderOptions.BitmapScalingMode="NearestNeighbor"
RenderOptions.EdgeMode="Aliased"/>
Monday, 23 July 2012
Software installing in one easy step
Use this handy utility next time you have to install a machine with base software. Aggregates all installers into one handy little setup...
Wednesday, 18 July 2012
Client side tools for Phone development
These are the client side tools that have just been mentioned for developing responsive web applications for mobile platform today on http://live.aspconf.net/
Frameworks to learn for SPAs
If you're thinking of building single page applications in future, then you will need to learn the following frameworks for sure..
Thursday, 12 July 2012
Handy SQL for extracting creating your test data insert scripts
SET NOCOUNT ON
GO
PRINT 'Checking for the existence of this procedure'
IF (SELECT OBJECT_ID('sp_generate_inserts','P')) IS NOT NULL --means, the procedure already exists
BEGIN
PRINT 'Procedure already exists. So, dropping it'
DROP PROC sp_generate_inserts
END
GO
CREATE PROC sp_generate_inserts
(
@table_name varchar(776), -- The table/view for which the INSERT statements will be generated using the existing data
@target_table varchar(776) = NULL, -- Use this parameter to specify a different table name into which the data will be inserted
@include_column_list bit = 1, -- Use this parameter to include/ommit column list in the generated INSERT statement
@from varchar(800) = NULL, -- Use this parameter to filter the rows based on a filter condition (using WHERE)
@include_timestamp bit = 0, -- Specify 1 for this parameter, if you want to include the TIMESTAMP/ROWVERSION column's data in the INSERT statement
@debug_mode bit = 0, -- If @debug_mode is set to 1, the SQL statements constructed by this procedure will be printed for later examination
@owner varchar(64) = NULL, -- Use this parameter if you are not the owner of the table
@ommit_images bit = 0, -- Use this parameter to generate INSERT statements by omitting the 'image' columns
@ommit_identity bit = 0, -- Use this parameter to ommit the identity columns
@top int = NULL, -- Use this parameter to generate INSERT statements only for the TOP n rows
@cols_to_include varchar(8000) = NULL, -- List of columns to be included in the INSERT statement
@cols_to_exclude varchar(8000) = NULL, -- List of columns to be excluded from the INSERT statement
@disable_constraints bit = 0, -- When 1, disables foreign key constraints and enables them after the INSERT statements
@ommit_computed_cols bit = 0 -- When 1, computed columns will not be included in the INSERT statement
)
AS
BEGIN
/***********************************************************************************************************
Procedure: sp_generate_inserts (Build 22)
(Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.)
Purpose: To generate INSERT statements from existing data.
These INSERTS can be executed to regenerate the data at some other location.
This procedure is also useful to create a database setup, where in you can
script your data along with your table definitions.
Written by: Narayana Vyas Kondreddi
Acknowledgements:
Divya Kalra -- For beta testing
Mark Charsley -- For reporting a problem with scripting uniqueidentifier columns with NULL values
Artur Zeygman -- For helping me simplify a bit of code for handling non-dbo owned tables
Joris Laperre -- For reporting a regression bug in handling text/ntext columns
Tested on: SQL Server 7.0 and SQL Server 2000 and SQL Server 2005
Date created: January 17th 2001 21:52 GMT
Date modified: May 1st 2002 19:50 GMT
Email: vyaskn@hotmail.com
NOTE: This procedure may not work with tables with too many columns.
Results can be unpredictable with huge text columns or SQL Server 2000's sql_variant data types
Whenever possible, Use @include_column_list parameter to ommit column list in the INSERT statement, for better results
IMPORTANT: This procedure is not tested with internation data (Extended characters or Unicode). If needed
you might want to convert the datatypes of character variables in this procedure to their respective unicode counterparts
like nchar and nvarchar
ALSO NOTE THAT THIS PROCEDURE IS NOT UPDATED TO WORK WITH NEW DATA TYPES INTRODUCED IN SQL SERVER 2005 / YUKON
Example 1: To generate INSERT statements for table 'titles':
EXEC sp_generate_inserts 'titles'
Example 2: To ommit the column list in the INSERT statement: (Column list is included by default)
IMPORTANT: If you have too many columns, you are advised to ommit column list, as shown below,
to avoid erroneous results
EXEC sp_generate_inserts 'titles', @include_column_list = 0
Example 3: To generate INSERT statements for 'titlesCopy' table from 'titles' table:
EXEC sp_generate_inserts 'titles', 'titlesCopy'
Example 4: To generate INSERT statements for 'titles' table for only those titles
which contain the word 'Computer' in them:
NOTE: Do not complicate the FROM or WHERE clause here. It's assumed that you are good with T-SQL if you are using this parameter
EXEC sp_generate_inserts 'titles', @from = "from titles where title like '%Computer%'"
Example 5: To specify that you want to include TIMESTAMP column's data as well in the INSERT statement:
(By default TIMESTAMP column's data is not scripted)
EXEC sp_generate_inserts 'titles', @include_timestamp = 1
Example 6: To print the debug information:
EXEC sp_generate_inserts 'titles', @debug_mode = 1
Example 7: If you are not the owner of the table, use @owner parameter to specify the owner name
To use this option, you must have SELECT permissions on that table
EXEC sp_generate_inserts Nickstable, @owner = 'Nick'
Example 8: To generate INSERT statements for the rest of the columns excluding images
When using this otion, DO NOT set @include_column_list parameter to 0.
EXEC sp_generate_inserts imgtable, @ommit_images = 1
Example 9: To generate INSERT statements excluding (ommiting) IDENTITY columns:
(By default IDENTITY columns are included in the INSERT statement)
EXEC sp_generate_inserts mytable, @ommit_identity = 1
Example 10: To generate INSERT statements for the TOP 10 rows in the table:
EXEC sp_generate_inserts mytable, @top = 10
Example 11: To generate INSERT statements with only those columns you want:
EXEC sp_generate_inserts titles, @cols_to_include = "'title','title_id','au_id'"
Example 12: To generate INSERT statements by omitting certain columns:
EXEC sp_generate_inserts titles, @cols_to_exclude = "'title','title_id','au_id'"
Example 13: To avoid checking the foreign key constraints while loading data with INSERT statements:
EXEC sp_generate_inserts titles, @disable_constraints = 1
Example 14: To exclude computed columns from the INSERT statement:
EXEC sp_generate_inserts MyTable, @ommit_computed_cols = 1
***********************************************************************************************************/
SET NOCOUNT ON
--Making sure user only uses either @cols_to_include or @cols_to_exclude
IF ((@cols_to_include IS NOT NULL) AND (@cols_to_exclude IS NOT NULL))
BEGIN
RAISERROR('Use either @cols_to_include or @cols_to_exclude. Do not use both the parameters at once',16,1)
RETURN -1 --Failure. Reason: Both @cols_to_include and @cols_to_exclude parameters are specified
END
--Making sure the @cols_to_include and @cols_to_exclude parameters are receiving values in proper format
IF ((@cols_to_include IS NOT NULL) AND (PATINDEX('''%''',@cols_to_include) = 0))
BEGIN
RAISERROR('Invalid use of @cols_to_include property',16,1)
PRINT 'Specify column names surrounded by single quotes and separated by commas'
PRINT 'Eg: EXEC sp_generate_inserts titles, @cols_to_include = "''title_id'',''title''"'
RETURN -1 --Failure. Reason: Invalid use of @cols_to_include property
END
IF ((@cols_to_exclude IS NOT NULL) AND (PATINDEX('''%''',@cols_to_exclude) = 0))
BEGIN
RAISERROR('Invalid use of @cols_to_exclude property',16,1)
PRINT 'Specify column names surrounded by single quotes and separated by commas'
PRINT 'Eg: EXEC sp_generate_inserts titles, @cols_to_exclude = "''title_id'',''title''"'
RETURN -1 --Failure. Reason: Invalid use of @cols_to_exclude property
END
--Checking to see if the database name is specified along wih the table name
--Your database context should be local to the table for which you want to generate INSERT statements
--specifying the database name is not allowed
IF (PARSENAME(@table_name,3)) IS NOT NULL
BEGIN
RAISERROR('Do not specify the database name. Be in the required database and just specify the table name.',16,1)
RETURN -1 --Failure. Reason: Database name is specified along with the table name, which is not allowed
END
--Checking for the existence of 'user table' or 'view'
--This procedure is not written to work on system tables
--To script the data in system tables, just create a view on the system tables and script the view instead
IF @owner IS NULL
BEGIN
IF ((OBJECT_ID(@table_name,'U') IS NULL) AND (OBJECT_ID(@table_name,'V') IS NULL))
BEGIN
RAISERROR('User table or view not found.',16,1)
PRINT 'You may see this error, if you are not the owner of this table or view. In that case use @owner parameter to specify the owner name.'
PRINT 'Make sure you have SELECT permission on that table or view.'
RETURN -1 --Failure. Reason: There is no user table or view with this name
END
END
ELSE
BEGIN
IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = @table_name AND (TABLE_TYPE = 'BASE TABLE' OR TABLE_TYPE = 'VIEW') AND TABLE_SCHEMA = @owner)
BEGIN
RAISERROR('User table or view not found.',16,1)
PRINT 'You may see this error, if you are not the owner of this table. In that case use @owner parameter to specify the owner name.'
PRINT 'Make sure you have SELECT permission on that table or view.'
RETURN -1 --Failure. Reason: There is no user table or view with this name
END
END
--Variable declarations
DECLARE @Column_ID int,
@Column_List varchar(8000),
@Column_Name varchar(128),
@Start_Insert varchar(786),
@Data_Type varchar(128),
@Actual_Values varchar(8000), --This is the string that will be finally executed to generate INSERT statements
@IDN varchar(128) --Will contain the IDENTITY column's name in the table
--Variable Initialization
SET @IDN = ''
SET @Column_ID = 0
SET @Column_Name = ''
SET @Column_List = ''
SET @Actual_Values = ''
IF @owner IS NULL
BEGIN
SET @Start_Insert = 'INSERT INTO ' + '[' + RTRIM(COALESCE(@target_table,@table_name)) + ']'
END
ELSE
BEGIN
SET @Start_Insert = 'INSERT ' + '[' + LTRIM(RTRIM(@owner)) + '].' + '[' + RTRIM(COALESCE(@target_table,@table_name)) + ']'
END
--To get the first column's ID
SELECT @Column_ID = MIN(ORDINAL_POSITION)
FROM INFORMATION_SCHEMA.COLUMNS (NOLOCK)
WHERE TABLE_NAME = @table_name AND
(@owner IS NULL OR TABLE_SCHEMA = @owner)
--Loop through all the columns of the table, to get the column names and their data types
WHILE @Column_ID IS NOT NULL
BEGIN
SELECT @Column_Name = QUOTENAME(COLUMN_NAME),
@Data_Type = DATA_TYPE
FROM INFORMATION_SCHEMA.COLUMNS (NOLOCK)
WHERE ORDINAL_POSITION = @Column_ID AND
TABLE_NAME = @table_name AND
(@owner IS NULL OR TABLE_SCHEMA = @owner)
IF @cols_to_include IS NOT NULL --Selecting only user specified columns
BEGIN
IF CHARINDEX( '''' + SUBSTRING(@Column_Name,2,LEN(@Column_Name)-2) + '''',@cols_to_include) = 0
BEGIN
GOTO SKIP_LOOP
END
END
IF @cols_to_exclude IS NOT NULL --Selecting only user specified columns
BEGIN
IF CHARINDEX( '''' + SUBSTRING(@Column_Name,2,LEN(@Column_Name)-2) + '''',@cols_to_exclude) <> 0
BEGIN
GOTO SKIP_LOOP
END
END
--Making sure to output SET IDENTITY_INSERT ON/OFF in case the table has an IDENTITY column
IF (SELECT COLUMNPROPERTY( OBJECT_ID(QUOTENAME(COALESCE(@owner,USER_NAME())) + '.' + @table_name),SUBSTRING(@Column_Name,2,LEN(@Column_Name) - 2),'IsIdentity')) = 1
BEGIN
IF @ommit_identity = 0 --Determing whether to include or exclude the IDENTITY column
SET @IDN = @Column_Name
ELSE
GOTO SKIP_LOOP
END
--Making sure whether to output computed columns or not
IF @ommit_computed_cols = 1
BEGIN
IF (SELECT COLUMNPROPERTY( OBJECT_ID(QUOTENAME(COALESCE(@owner,USER_NAME())) + '.' + @table_name),SUBSTRING(@Column_Name,2,LEN(@Column_Name) - 2),'IsComputed')) = 1
BEGIN
GOTO SKIP_LOOP
END
END
--Tables with columns of IMAGE data type are not supported for obvious reasons
IF(@Data_Type in ('image'))
BEGIN
IF (@ommit_images = 0)
BEGIN
RAISERROR('Tables with image columns are not supported.',16,1)
PRINT 'Use @ommit_images = 1 parameter to generate INSERTs for the rest of the columns.'
PRINT 'DO NOT ommit Column List in the INSERT statements. If you ommit column list using @include_column_list=0, the generated INSERTs will fail.'
RETURN -1 --Failure. Reason: There is a column with image data type
END
ELSE
BEGIN
GOTO SKIP_LOOP
END
END
--Determining the data type of the column and depending on the data type, the VALUES part of
--the INSERT statement is generated. Care is taken to handle columns with NULL values. Also
--making sure, not to lose any data from flot, real, money, smallmomey, datetime columns
SET @Actual_Values = @Actual_Values +
CASE
WHEN @Data_Type IN ('char','varchar','nchar','nvarchar')
THEN
'COALESCE('''''''' + REPLACE(RTRIM(' + @Column_Name + '),'''''''','''''''''''')+'''''''',''NULL'')'
WHEN @Data_Type IN ('datetime','smalldatetime')
THEN
'COALESCE('''''''' + RTRIM(CONVERT(char,' + @Column_Name + ',109))+'''''''',''NULL'')'
WHEN @Data_Type IN ('uniqueidentifier')
THEN
'COALESCE('''''''' + REPLACE(CONVERT(char(255),RTRIM(' + @Column_Name + ')),'''''''','''''''''''')+'''''''',''NULL'')'
WHEN @Data_Type IN ('text','ntext')
THEN
'COALESCE('''''''' + REPLACE(CONVERT(char(8000),' + @Column_Name + '),'''''''','''''''''''')+'''''''',''NULL'')'
WHEN @Data_Type IN ('binary','varbinary')
THEN
'COALESCE(RTRIM(CONVERT(char,' + 'CONVERT(int,' + @Column_Name + '))),''NULL'')'
WHEN @Data_Type IN ('timestamp','rowversion')
THEN
CASE
WHEN @include_timestamp = 0
THEN
'''DEFAULT'''
ELSE
'COALESCE(RTRIM(CONVERT(char,' + 'CONVERT(int,' + @Column_Name + '))),''NULL'')'
END
WHEN @Data_Type IN ('float','real','money','smallmoney')
THEN
'COALESCE(LTRIM(RTRIM(' + 'CONVERT(char, ' + @Column_Name + ',2)' + ')),''NULL'')'
ELSE
'COALESCE(LTRIM(RTRIM(' + 'CONVERT(char, ' + @Column_Name + ')' + ')),''NULL'')'
END + '+' + ''',''' + ' + '
--Generating the column list for the INSERT statement
SET @Column_List = @Column_List + @Column_Name + ','
SKIP_LOOP: --The label used in GOTO
SELECT @Column_ID = MIN(ORDINAL_POSITION)
FROM INFORMATION_SCHEMA.COLUMNS (NOLOCK)
WHERE TABLE_NAME = @table_name AND
ORDINAL_POSITION > @Column_ID AND
(@owner IS NULL OR TABLE_SCHEMA = @owner)
--Loop ends here!
END
--To get rid of the extra characters that got concatenated during the last run through the loop
SET @Column_List = LEFT(@Column_List,len(@Column_List) - 1)
SET @Actual_Values = LEFT(@Actual_Values,len(@Actual_Values) - 6)
IF LTRIM(@Column_List) = ''
BEGIN
RAISERROR('No columns to select. There should at least be one column to generate the output',16,1)
RETURN -1 --Failure. Reason: Looks like all the columns are ommitted using the @cols_to_exclude parameter
END
--Forming the final string that will be executed, to output the INSERT statements
IF (@include_column_list <> 0)
BEGIN
SET @Actual_Values =
'SELECT ' +
CASE WHEN @top IS NULL OR @top < 0 THEN '' ELSE ' TOP ' + LTRIM(STR(@top)) + ' ' END +
'''' + RTRIM(@Start_Insert) +
' ''+' + '''(' + RTRIM(@Column_List) + '''+' + ''')''' +
' +''VALUES(''+ ' + @Actual_Values + '+'')''' + ' ' +
COALESCE(@from,' FROM ' + CASE WHEN @owner IS NULL THEN '' ELSE '[' + LTRIM(RTRIM(@owner)) + '].' END + '[' + rtrim(@table_name) + ']' + '(NOLOCK)')
END
ELSE IF (@include_column_list = 0)
BEGIN
SET @Actual_Values =
'SELECT ' +
CASE WHEN @top IS NULL OR @top < 0 THEN '' ELSE ' TOP ' + LTRIM(STR(@top)) + ' ' END +
'''' + RTRIM(@Start_Insert) +
' '' +''VALUES(''+ ' + @Actual_Values + '+'')''' + ' ' +
COALESCE(@from,' FROM ' + CASE WHEN @owner IS NULL THEN '' ELSE '[' + LTRIM(RTRIM(@owner)) + '].' END + '[' + rtrim(@table_name) + ']' + '(NOLOCK)')
END
--Determining whether to ouput any debug information
IF @debug_mode =1
BEGIN
PRINT '/*****START OF DEBUG INFORMATION*****'
PRINT 'Beginning of the INSERT statement:'
PRINT @Start_Insert
PRINT ''
PRINT 'The column list:'
PRINT @Column_List
PRINT ''
PRINT 'The SELECT statement executed to generate the INSERTs'
PRINT @Actual_Values
PRINT ''
PRINT '*****END OF DEBUG INFORMATION*****/'
PRINT ''
END
PRINT '--INSERTs generated by ''sp_generate_inserts'' stored procedure written by Vyas'
PRINT '--Build number: 22'
PRINT '--Problems/Suggestions? Contact Vyas @ vyaskn@hotmail.com'
PRINT '--http://vyaskn.tripod.com'
PRINT ''
PRINT 'SET NOCOUNT ON'
PRINT ''
--Determining whether to print IDENTITY_INSERT or not
IF (@IDN <> '')
BEGIN
PRINT 'SET IDENTITY_INSERT ' + QUOTENAME(COALESCE(@owner,USER_NAME())) + '.' + QUOTENAME(@table_name) + ' ON'
PRINT 'GO'
PRINT ''
END
IF @disable_constraints = 1 AND (OBJECT_ID(QUOTENAME(COALESCE(@owner,USER_NAME())) + '.' + @table_name, 'U') IS NOT NULL)
BEGIN
IF @owner IS NULL
BEGIN
SELECT 'ALTER TABLE ' + QUOTENAME(COALESCE(@target_table, @table_name)) + ' NOCHECK CONSTRAINT ALL' AS '--Code to disable constraints temporarily'
END
ELSE
BEGIN
SELECT 'ALTER TABLE ' + QUOTENAME(@owner) + '.' + QUOTENAME(COALESCE(@target_table, @table_name)) + ' NOCHECK CONSTRAINT ALL' AS '--Code to disable constraints temporarily'
END
PRINT 'GO'
END
PRINT ''
PRINT 'PRINT ''Inserting values into ' + '[' + RTRIM(COALESCE(@target_table,@table_name)) + ']' + ''''
--All the hard work pays off here!!! You'll get your INSERT statements, when the next line executes!
EXEC (@Actual_Values)
PRINT 'PRINT ''Done'''
PRINT ''
IF @disable_constraints = 1 AND (OBJECT_ID(QUOTENAME(COALESCE(@owner,USER_NAME())) + '.' + @table_name, 'U') IS NOT NULL)
BEGIN
IF @owner IS NULL
BEGIN
SELECT 'ALTER TABLE ' + QUOTENAME(COALESCE(@target_table, @table_name)) + ' CHECK CONSTRAINT ALL' AS '--Code to enable the previously disabled constraints'
END
ELSE
BEGIN
SELECT 'ALTER TABLE ' + QUOTENAME(@owner) + '.' + QUOTENAME(COALESCE(@target_table, @table_name)) + ' CHECK CONSTRAINT ALL' AS '--Code to enable the previously disabled constraints'
END
PRINT 'GO'
END
PRINT ''
IF (@IDN <> '')
BEGIN
PRINT 'SET IDENTITY_INSERT ' + QUOTENAME(COALESCE(@owner,USER_NAME())) + '.' + QUOTENAME(@table_name) + ' OFF'
PRINT 'GO'
END
PRINT 'SET NOCOUNT OFF'
SET NOCOUNT OFF
RETURN 0 --Success. We are done!
END
GO
PRINT 'Created the procedure'
GO
--Mark procedure as system object
EXEC sys.sp_MS_marksystemobject sp_generate_inserts
GO
PRINT 'Granting EXECUTE permission on sp_generate_inserts to all users'
GRANT EXEC ON sp_generate_inserts TO public
SET NOCOUNT OFF
GO
PRINT 'Done'
How to find the last interactive logons in Windows using PowerShell
Use the following powershell script to find the last users to login to a box since a given date, in this case the 21st April 2022 at 12pm un...
-
Example... Add this to your controls namespace declarations xmlns:MyNameSpace="clr-namespace:MyNameSpace;assembly=MyAssembly" t...
-
http://www.jaguarforums.com/forum/s-type-s-type-r-supercharged-v8-15/key-fob-battery-replacement-write-up-faq-54380/ NOTE: MAKE SURE YOU DO ...