Wednesday, 23 December 2009

TSQL: Granting Permissions

GRANT INSERT ON table
TO sqluser
GO

GRANT UPDATE ON table
TO sqluser
GO

SQL Profiler: Wild Cards

When adding wild cards to filter by textdata column, be sure to include the percentage characters around your text string.

For example:

%WHERE bass = null%

Friday, 18 December 2009

TSQL: Newline, Carraige returns into char or varcahr field

To insert new line + carraige returns (\r\n) into a char or a varchar field you'll need to convert the to char(13)+char(10) before running your UPDATES or INSERTS.

Tuesday, 15 December 2009

Sysadmin: cURL

Found a very powerful commandline tool for transferring data across a multitude of protocols.
"curl is a tool to transfer data from or to a server, using one of the supported protocols (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, TFTP, DICT, TELNET, LDAP or FILE). The command is designed to work without user interaction."
http://curl.haxx.se/

Adobe AIR: Getting Started

Adobe AIR
" Adobe AIR is a cross-operating system runtime that enables you to use your existing HTML/Ajax, Flex, or Flash web development skills and tools to build and deploy rich Internet applications to the desktop.

Adobe AIR applications support native desktop integration, including clipboard and drag-and-drop support, local file IO, system notification, and more. " - http://www.adobe.com/devnet/air/

Essentially, AIR allows you to easily package up your browser based web application created in HTML/AJAX/Flash/Flex and deploy it to clients as a desktop application.

Getting Started

To start you'll need to download the Adobe AIR SDK. The SDK is available from Adobe's website. The SDK contains the necessary javascript libraries and also a debugger, packaging utility for creation of installation files AND self-signed certificate generator. There is no IDE that comes with the SDK. Current version is 1.5.3

For an IDE you can use any text editor, but if you wish to have a GUI interface, the options are to use Aptana Studio or Adobe Dreaweaver CS3/CS4 with Adobe Air Extensions for Dreamweaver.

A step by step guide to writing your first Hello World AIR application using any text editor can be found here.

http://help.adobe.com/en_US/AIR/1.5/devappshtml/WS5b3ccc516d4fbf351e63e3d118666ade46-7ecc.html

Interesting

Wednesday, 9 December 2009

JQUERY: Get select value and text

Get Value:

$('#selectList').val();

Get Text:

$('#selectList :selected').text()

Get Multiple Text:

var foo = [];
$('#multiple :selected').each(function(i, selected){
foo[i] = $(selected).text();
});

Thursday, 19 November 2009

XML, XSLT - Equivalent CASE statement in XSLT

 1: <poem author="jm" year="1667">
 2:  <verse>Seest thou yon dreary Plain, forlorn and wild,</verse>
 3:  <verse>The seat of desolation, void of light,</verse>
 4:  <verse>Save what the glimmering of these livid flames</verse>
 5:  <verse>Casts pale and dreadful?</verse>
 6: </poem>
 7:  
 8: <xsl:template match="poem">
 9:  
 10:  <xsl:choose>
 11:  <xsl:when test="@year < 1638">
 12:  The poem is one of Milton's earlier works.
 13:  </xsl:when>
 14:  
 15:  <xsl:when test="@year < 1650">
 16:  The poem is from Milton's middle period.
 17:  </xsl:when>
 18:  
 19:  <xsl:when test="@year < 1668">
 20:  The poem is one of Milton's later works.
 21:  </xsl:when>
 22:  
 23:  <xsl:when test="@year < 1675">
 24:  The poem is one of Milton's last works.
 25:  </xsl:when>
 26:  
 27:  <xsl:otherwise>
 28:  The poem was written after Milton's death.
 29:  </xsl:otherwise>
 30:  
 31:  </xsl:choose>
 32:  
 33: </xsl:template>

XML, XSLT - Beginner's Guide

Create 2 files, 1 XML the other XSLT.
Populate the XML file with your XML data.
Reference your XSLT by using the following syntax.

1: <?xml-stylesheet type="text/xsl" href="poem.xslt"?>

Host your XML file on your webserver and open the XML file in your browser to view the transformed XML.

Thursday, 5 November 2009

Windows 7: System crashed, lost administrative privileges to exfat drive

I'm running Windows 7 RTM, computer just crashed an hour ago and have noticed that I've lost write access to my D drive formatted in exFat, what gives??

Seems like the entire partition has been reset with a readonly flag.

Seen a couple of solutions on the net.

Try running a new command window in elevated mode, change to drive and run "chkdsk /f".

Or try using diskpart > select disk xx > select vol xx > att vol clear readonly

The diskpart didn't work for me, but chkdsk worked!! Sigh... haven't had to do chkdsk since windows98.

Wednesday, 21 October 2009

MS Outlook: Not retrieving your style sheet

Scenario:

Have created a tool that generates a HTML email.
HTML email has references to Custom Style Sheets hosted on the corporate intranet.
The email is sent company wide to own domain and also to a child company with its own domain.
Cross domain trust is limited but the child company is able to access the parent intranet.
The email renders correctly on parent domain, but on child domain none of the styles came through.

Fix:

Seems like outlook was the culprit, and was blocking scripts on the email. This includes my reference to the stylesheet on the parent domain.

Needed to modify outlook to add sender as a safe sender in the junk mail filter list.

Steps to do this are outlined here:


Once the sender was added to the safe sender list, the email renders correctly.

If you double click on the email and click on "View" > "View in internet zone" the styles should also become visible.

Thursday, 8 October 2009

Active Directory: Query convention

Using ADs path format:
LDAP:<//server/o=organization/ou=site/cn=recipients>;
(objectClass=*);ADsPath,objectClass,cn;subtree"

Attribute name format:
<LDAP://server/cn=recipients,ou=site,o=organization>, _
(objectClass=*);ADsPath,objectClass;subtree

SAMPLE CODE:

Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset

Set conn = New ADODB.Connection
conn.Provider = "ADSDSOObject"
conn.Open "ADs Provider"

Set rs = conn.Execute( _
"<LDAP://server/o=organization/ou=site/cn=recipients>;" _
& "(objectClass=*);ADsPath,objectClass,cn;subtree")

While Not rs.EOF
Debug.Print rs.Fields(0).Value, rs.Fields(1).Value, _
rs.Fields(2).Value
rs.MoveNext
Wend

conn.Close

Thursday, 1 October 2009

Javascript: Prevent editing in file input fields

add the following properties:

oncontextmenu='return false' onkeydown='this.blur()'

Wednesday, 30 September 2009

Flash: Allows flash to layer under div elements

You can do it by placing

<param name="wmode" value="transparent">

in your flash area. You will also need to add

wmode="transparent"

to the "embed" area of your flash.

Friday, 18 September 2009

CSS: Z-Index law

Z-index will only work if a position attribute is applied to its elements.

CSS: Z-Index and getting around IE6 lack of support for this property

This is an interesting post to get around IE's bug when applying z-index to elements.

http://www.macridesweb.com/oltest/IframeShim.html

The idea is to wrap an Iframe around your element where z-index is required.

For transparency apply the alpha filter to make the actual iframe transparent. Even though its transparent, it will still hide IE's window elements e.g. select boxes away from view.

iframe.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';

Wednesday, 16 September 2009

Batch Scripting: Environment Dates

Encountered a funny issue in our staging environment.
Seems like the environment date - %date% is user profile dependant.

If I run echo %date% using my account - I get 16/09/2009
If I run echo %date% using a service account - I get Wed 16/09/2009

Workaround is to strip the dayofweek from the above dates and then split each day, month and year component from the and reassemble each component manually.

For /F "tokens=1-4 delims=/ " %%i in ('date /t') Do (
Set _1=%%i
Set _2=%%j
Set _3=%%k
Set _4=%%l
)
:: Assign to datestamp and split out each date component to associated variable
:: Check for case when date stamp doesn't include day of week
If (%_4%)==() (
Set _datestamp=%_3%%_2%%_1%
Set _year=%_3%
Set _month=%_2%
Set _day=%_1%
) else (
Set _datestamp=%_4%%_3%%_2%
Set _year=%_4%
Set _month=%_3%
Set _day=%_2%
)

Monday, 10 August 2009

IIS: Resyncing Anonymous User Account Password

This error can occur if the password for the user account that is used for anonymous access in IIS is not synchronized with one of the following passwords:
  • The password for the user account in Active Directory
  • The password for the user account in Local Users and Groups
To synchronize the IIS password with the password that is used in Active Directory or in Local Users and Groups, follow these steps:

1. Click Start, click Run, type cmd, and then click OK.

2. Use the cd command to connect to the folder where the Adsutil.vbs file is located. By default, the Adsutil.vbs file is located in the following folder:
drive:\Inetpub\Adminscripts
Note drive is the folder where Windows is installed.

3. At the command prompt, type Cscript adsutil.vbs get w3svc/anonymoususerpass, and then press ENTER. Note the password that is generated.

Note You may have to set the Issecure property in the Adsutil.vbs file to False before you generate a password. To do this, follow these steps:

a. In Notepad, open the Adsutil.vbs file.
b. On the Edit menu, click Find, type IsSecureProperty = True, and then click Find Next.
c. Change “IsSecureProperty = True” to “IsSecureProperty = False”.
d. Save the changes, and then close Notepad.

4. Click Start, click Run, type Dsa.msc, and then click OK.

Note If the Web server is a stand-alone server, type Lusrmgr.msc.

5. Expand the domain that you want, and then click Users. If the Web server is a stand-alone server, click Users.

6. Right-click the user account that you want, and then click Reset Password or Set Password.

7. Type the password that you obtained in step 3 two times, and then click OK.

http://support.microsoft.com/kb/909887

Tuesday, 21 July 2009

HTML: optgroup

Grouping drop down items together:


Wednesday, 8 July 2009

SEO: Google analytics workaround for non-FQDN sites

we've setup google analytics on our external facing internet site and its been running great for the past year.
But now, we're looking at employing the same solution to our intranet.
Reading the FAQ on google, states that analytics requires two things for it to work correctly.

First, your internal network needs to be able to access certain resource files located on google's server.
Secondly, the site needs to have a FQDN (Fully Qualified Domain Name).

My problem is our intranet doesn't have an FQDN.
Read a few posts that there is a simple workaround for this.

First, copy the google tracking code and add it to a page on a site that does have a FQDN.

Add the _setDomainName property to the code, just beneath the variable declaration for pageTracker.
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._setDomainName("none");

Change your settings in analytics to point to the location of the temporary site.
Confirm tracking code is working and leave it overnight to collect stats.

Once a day's worth of stats have been collected, you can remove the tracking code on your temporary site and append the code to your intranet site.

Analytics will continue tracking your site as if nothing has changed =)

Thursday, 2 July 2009

VS2003: Change or Move location of VSwebcache folder

The cache is usually located at :-

C:\Documents and Settings\username\VSWebCache
.

The path can be changed but only via the windows registry :-

HKCU\Software\Microsoft\VisualStudio\7.1\WebProject\OfflineCacheDir
.

Wednesday, 3 June 2009

TSQL: SQLNotify

Add this to the master database:

Useful for SQL Jobs used to notify failures and successes:

To use:

exec master.dbo.sp_sqlnotify 'From email','To email semi-colon separated','Subject','Body'

CREATE PROCEDURE [dbo].[sp_SQLNotify]
@From varchar(100) ,
@To varchar(100) ,
@Subject varchar(100)=" ",
@Body varchar(4000) = ""
/*********************************************************************

This stored procedure takes the above parameters and sends an e-mail.
All of the mail configurations are hard-coded in the stored procedure.
Comments are added to the stored procedure where necessary.
Reference to the CDOSYS objects are at the following MSDN Web site:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_messaging.asp

***********************************************************************/
AS
Declare @iMsg int
Declare @hr int
Declare @source varchar(255)
Declare @description varchar(500)
Declare @output varchar(1000)

--************* Create the CDO.Message Object ************************
EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUT

--***************Configuring the Message Object ******************
-- This is to configure a remote SMTP server.
-- http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_schema_configuration_sendusing.asp
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'
-- This is to configure the Server Name or IP address.
-- Replace MailServerName by the name or IP of your SMTP Server.
EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value', 'your mail server'

-- Save the configurations to the message object.
EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null

-- Set the e-mail parameters.
EXEC @hr = sp_OASetProperty @iMsg, 'To', @To
EXEC @hr = sp_OASetProperty @iMsg, 'From', @From
EXEC @hr = sp_OASetProperty @iMsg, 'Subject', @Subject

-- If you are using HTML e-mail, use 'HTMLBody' instead of 'TextBody'.
EXEC @hr = sp_OASetProperty @iMsg, 'TextBody', @Body
EXEC @hr = sp_OAMethod @iMsg, 'Send', NULL

-- Sample error handling.
IF @hr <>0
select @hr
BEGIN
EXEC @hr = sp_OAGetErrorInfo NULL, @source OUT, @description OUT
IF @hr = 0
BEGIN
SELECT @output = ' Source: ' + @source
PRINT @output
SELECT @output = ' Description: ' + @description
PRINT @output
END
ELSE
BEGIN
PRINT ' sp_OAGetErrorInfo failed.'
RETURN
END
END

-- Do some error handling after each step if you need to.
-- Clean up the objects created.
EXEC @hr = sp_OADestroy @iMsg

PRINT 'Mail Sent!'




GO

Wednesday, 13 May 2009

AJAX: IE's autocomplete getting in your way

IE 6's autocomplete window was getting in the way of my input textbox.
It was hindering my javascript onblur event when you select a value from autocomplete with your mouse.

To stop this and get my onblur event working, I had to disable the autocomplete on my form.

To do this just add a new attribute to the tag.

Autocomplete=off

Monday, 11 May 2009

WSS3.0: Sharepoint Lists - modify default CRUD forms

REF : http://blog.henryong.com/2007/09/05/how-to-edit-the-form-fields-of-a-sharepoint-list/

Here’s an often forgotten feature that any SharePoint Designer person should be aware of. It’s the ability to edit and customize the default form fields for any list. This is made possible by using SharePoint Designer to navigate and open the form page that you want to edit. When you open the page you’ll see something like this:

You’ve probably tried right clicking around, trying to convert the web part to a dataview web part, and then you threw up your hands and said this is impossible!

But wait! Check this out… First select the ListFormWebPart and *EDIT: DO NOT hit the delete key. Instead hide the webpart. If you delete it, this will happen: http://support.microsoft.com/kb/935504

Ta da! Now you can go about your daily business of form customizations.

Thursday, 7 May 2009

TSQL: Email Notifications

Method 1:

When setting up a new SQL job, you can add additional steps after the job has run.

In the command area, type in the following to send an email:

exec master.dbo.sp_sqlnotify '[from email]','[to email 1];[to email 2]','[subject]','[msg body].'



Setup 2 additional steps, one for failure and one for success (only if you want to be notified on success), point the actions on Step 1 to the additional steps.








Wednesday, 29 April 2009

Sysadmin: Replace comma with linebreak character

In Microsoft Word:

1. Select: Edit/Find then go to the Replace tab. On that screen, you may have to press the button that says "More"

2. Click onto the Find What field, then click the "Special" Button at the bottom of the Window. Select "White Space."

3. Click onto the Replace with field, then click "Special" Button again. This time, select "Paragraph Mark."

4. Click the "Replace All" Button. The job is done.

Monday, 27 April 2009

TSQL: JOINS

Joins can be categorized as:

Inner joins (the typical join operation, which uses some comparison operator like = or <>). These include equi-joins and natural joins.
Inner joins use a comparison operator to match rows from two tables based on the values in common columns from each table. For example, retrieving all rows where the student identification number is the same in both the students and courses tables.

Outer joins. Outer joins can be a left, a right, or full outer join.
Outer joins are specified with one of the following sets of keywords when they are specified in the FROM clause:

LEFT JOIN or LEFT OUTER JOIN
The result set of a left outer join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.

RIGHT JOIN or RIGHT OUTER JOIN.
A right outer join is the reverse of a left outer join. All rows from the right table are returned. Null values are returned for the left table any time a right table row has no matching row in the left table.

FULL JOIN or FULL OUTER JOIN.
A full outer join returns all rows in both the left and right tables. Any time a row has no match in the other table, the select list columns from the other table contain null values. When there is a match between the tables, the entire result set row contains data values from the base tables.

Cross joins.
Cross joins return all rows from the left table, each row from the left table is combined with all rows from the right table. Cross joins are also called Cartesian products.

=============================

A join is used to combine columns from two or more tables into a single result set. To join data from two tables you write the names of two tables in the FROM clause along with JOIN keyword and an ON phrase that specifies the join condition. The join condition indicates how two tables should be compared. In most cases they are compares on the base on the relationship of primary key of the first table and foreign key of the second table.

I have two tables - Vendor table and Advance table.

Now we are going to apply joins on these tables and see the data results.

Inner Joins
An inner join requires each record in the two joined tables to have a matching record. An inner join essentially combines the records from two tables (A and B) based on a given join-predicate. The result of the join can be defined as the outcome of first taking the Cartesian product (or cross-join) of all records in the tables (combining every record in table A with every record in table B) - then return all records which satisfy the join predicate. Actual SQL implementations will normally use other approaches where possible, since computing the Cartesian product is not very efficient. This type of join occurs most commonly in applications, and represents the default join-type.
Example: This is explicit inner join:

e.g. (T-SQL for Inner Join)


SELECT v.VendorId, v.VendorFName, v.VendorLName, a.royality, a.advance
FROM dbo.Vendor as v
INNER JOIN advance as a
ON v.VendorId = a.VendorId
WHERE v.VendorId <= 5
GO
Example: This is implicit inner join:
Use Vendor
GO

SELECT * FROM Vendor, advance
WHERE Vendor.VendorId = advance.VendorId AND Vendor.VendorId <= 5
GO



Cross Join
A cross join, Cartesian join or product provides the foundation upon which all types of inner joins operate. A cross join returns the Cartesian product of the sets of records from the two joined tables. Thus, it equates to an inner join where the join-condition always evaluates to True or join-condition is absent in statement.

e.g. (T-SQL for Cross Join)

SELECT * FROM Vendor CROSS JOIN advance
GO
Use Vendor
GO
SELECT * FROM Vendor, advance
GO



Outer Joins
An outer join retrieves all rows that satisfy the join condition plus unmatched rows in one or both tables. In most cases you use the equal operator to retrieve rows with matching columns. However you can also use any of the other comparison operators. When row with unmatched columns is retrieved any columns from the other table that are included in the result are given null values.

Note1: The OUTER keyword is optional and typically omitted
Note2: You can also code left outer joins and right outer joins using the implicit syntax.

Three types of outer joins.
1. Left Outer Join
The result of a left outer join (or simply left join) for tables A and B always contains all records of the "left" table (A), even if the join-condition does not find any matching record in the "right" table (B). This means that if the ON clause matches 0 (zero) records in B, the join will still return a row in the result but with NULL in each column from B. This means that a left outer join returns all the values from the left table, plus matched values from the right table (or NULL in case of no matching join predicate).

e.g. (T-SQL for Left Outer Join)

SELECT VendorFName, Vendor.VendorId, VendorLName, Advance
FROM Vendor LEFT JOIN advance
ON Vendor.VendorId = advance.VendorId
GO


2. Right Outer Join
A right outer join (or right join) closely resembles a left outer join, except with the tables reversed. Every record from the "right" table (B) will appear in the joined table at least once. If no matching row from the "left" table (A) exists, NULL will appear in columns from A for those records that have no match in A.

e.g. (T-SQL for Right Outer Join)


SELECT VendorFName, advance.VendorId, VendorLName, Advance
FROM Vendor RIGHT JOIN advance
ON Vendor.VendorId = advance.VendorId
GO

3. Full outer join
A full outer join combines the results of both left and right outer joins. The joined table will contain all records from both tables, and fill in NULLs for missing matches on either side.

e.g. (T-SQL for Full Outer Join)

SELECT * FROM Vendor FULL OUTER JOIN advance
ON Vendor.VendorId = advance.VendorId

Tuesday, 21 April 2009

VS2008: Generate new GUID quickly

Source: http://mundeep.wordpress.com/2008/03/27/quickly-generating-guids-in-visual-studio-2008/

One of the common tasks involved when creating sharepoint solutions is the generation of GUIDs. Visual Studio comes with a tool called GuidGen that lets you create GUIDs however it is annoying having to leave the Visual Studio environment.

I believe Visual Studio 2005 used to have it as an option under the Tools menu however i haven’t found where i can add the same shortcut in Visual Studio Team System 2008 (though i do notice that Visual Studio 2008 Professional DOES have a “Create GUID” shortcut under Tools - i’d still prefer the macro shortcut for ease of use especially when creating a lot of features).

I have however found a nifty alternate solution by Leon Zandman that describes creating a Macro to insert a guid into your current file. I’d just like to clarify some of the steps for those that haven’t dealt with Macros in Visual Studio 2008 before.

  1. Load Visual Studio 2008 and goto Tools -> Macros -> Macro Explorer (Alt-F8 for short)Macro Explorer
  2. Right-click on “Macros” then select New Macro Project
  3. Name your project (eg. GUIDGenerator) and choose a location to save it (note no space allowed in Project Name).
  4. This should give you a new project with a “Module1″ sitting underneath it. Right-click on “Module1″ and select “Rename” to give it a more meaningful name (eg. GUIDGenModule).
  5. Double-click on the newly renamed module and you should be shown the Visual Studio Macro IDE.
  6. Enter the following code (the “D” in ToString can be customised see Leon’s article):
      1. Sub Create_GUID()
      2. DTE.ActiveDocument.Selection.Text = System.Guid.NewGuid().ToString("D").ToUpper()
      3. End Sub
  7. Save and close the Macro IDE.
  8. Back in the main Visual Studio window goto Tools -> Options
  9. Goto the “Keyboard” option under the “Environment” tab.
  10. In the “Show Commands Containing” text box type in “Create_GUID”
  11. Select the Macro sub that you just created from the list (it should be the only one)
  12. Click inside the “Press Shortcut Keys” textbox then press your desired keyboard shortcut for inserting a GUID (eg. Alt+G as Leon suggested makes a lot of sense).
  13. Ensure the “Use Shortcut in” option is “Global” and click on “Assign”
  14. Close the options window and you should be able to start using your keyboard shortcut to quickly insert GUIDs into text!
  15. If you have any other Visual Studio windows open at the time you will need to close them and reload for the macro for the macro to be loaded (or you can goto the Macro Explorer window and manually load your Macro project)

HTML: Mailto with amphersand character

Replace "&" character with %26

Friday, 17 April 2009

WSS3.0: Treeview and SPSiteMapProvider

ARRRGHHH! this caused me much headache!

Finally figured it out.

Problem:

The dynamic treeview displays correctly in SharePoint Designer, why doesn't it expand fully while viewed through the web browser.

Make sure you've set the property "PopulateNodesFromClient" to false.

Thursday, 16 April 2009

WSS3.0: Checking multiple files into libraries

WSS being the freebie tool that it is, doesn't provide any easy way for end users to check-in multiple files.

But if you have Sharepoint Designer, you can get around this limitation as it allows you to connect to your site and manage multiple file check-ins.

Thursday, 9 April 2009

Excel: CSV schema file

When reading data programmatically from a CSV file via ASP, datatypes for each columns are determined by an initial scan of the first few rows of the file.
This does not give an accurate representation of the data type of each column.
You can define a schema.ini file and position this file in the same folder as the csv.
The schema file is loaded when required and contains custom attributes used when reading the csv file.

e.g.

SCHEMA.INI

[YOURCSVFILE.csv]
ColNameHeader=False
MaxScanRows=0
Format=CSVDelimited

Wednesday, 1 April 2009

Excel: Text to Number

Use the Text to Columns Command

This method works best if the data is arranged in a single column. The following example assumes that the data is in column A and starts in row 1 ($A$1). To use this example, follow these steps:
  1. Select one column of cells that contain the text.
  2. On the Data menu, click Text to Columns.
  3. Under Original data type, click Delimited, and click Next.
  4. Under Delimiters, click to select the Tab check box, and click Next.
  5. Under Column data format, click General.
  6. Click Advanced and make any appropriate settings for the Decimal separator and Thousands separator. Click OK.
  7. Click Finish.

Wednesday, 11 March 2009

Javascript: A list of Javascript Framework

Thought I'll compile a list of common javascript framework/libraries that i've come across:
List will be built up gradually.

jQuery - http://jquery.com/
prototype - http://www.prototypejs.org/
mootools - http://mootools.net/
moofx - http://moofx.mad4milk.net/
ExtJS - http://extjs.com/
script.aculo.us - http://script.aculo.us/

Wednesday, 4 March 2009

Persits ASPEncrypt: Encrypt uploads and Decrypt downloads

Downloaded demo version of ASPEncrypt from persits website.
Needed to provide AES (Advanced Encryption Standard) level encryption based on Rijndael - developed by two Belgian crytographers named, Joan Daemen and Vincent Rijmen - name was a portmanteau of their names.

Anyway, couple of issues :

i look at the samples available from ASPEncrypt. These are installed under the Persits folder under program files.

The sample I worked of was located in the "upload_download" folder.

I changed the default CSP provider so I can use AES256. The docos provided regarding the naming of the CSP was a bit vague. All it said was to include the words prototype if you're on an XP machine. Tried to prefix to start with but didn't work, then end up looking in the registry for actual CSP name.

Check registry in the following locations to see list of CSP installed on server:

HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Providers

Code now changed to:


Set Upload = Server.CreateObject("Persits.Upload")
Set CM = Server.CreateObject("Persits.CryptoManager")
Set Context = CM.OpenContextEx("Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype)", "mycontainer", True )
Set Key = Context.GenerateKeyFromPassword("password", , calgAES256) ' use defaults
'Key.EncryptText("Some text")
Upload.SaveEncrypted "c:\upload", Key, "xxx"

For Each File in Upload.Files
Response.Write "Name=" & File.Path & "; Size=" & File.Size & "
"
Next


This still threw an error for me :

Persits.CryptoManager.1 (0x800A0009)
Invalid algorithm specified.

Found out I needed the following metadata as well to allow the use of the following macros "calgAES256"


METADATA TYPE="TypeLib" UUID="{B72DF063-28A4-11D3-BF19-009027438003}"


Enclose them in a set of HTML comment tags.

Thursday, 26 February 2009

C#: Needed to automagically embed images into an email from a html source

Found this excellent code that handles this beautifully.

http://www.codeproject.com/KB/IP/Mail_Webpage_with_images.aspx?display=Print

Friday, 20 February 2009

CAML: Referencing column names in WSS List with spaces

Need to replace the space with "_x0020_"

CAML: Found a Good Guide

http://www.u2u.be/Res/Article.aspx?ART=WritingCAMLQueries

WSS3.0: Update WSS List via webservices

1) Open Visual Studio.NET 2003

2) New Project (We will create a console application in this demo)

3) Name your project "GetListItems"

4) Right Click on "References" under the Project and select "Add Web Reference"

5) In the URL field type the path to your Windows SharePoint Services Site that contains the list you want to use.

Each site is different and only contains the lists for the particular child site.

For example the root site could be called "http://sharepoint.mysite.com" and you could have a sub site called "Test" which is accessible via "http://sharepoint.mysite.com/Test"

So type in your URL and append the following "_vti_bin/lists.asmx"

So if you were going to the "Test" child site your URL would be like this:

http://sharepoint.mysite.com/Test/_vti_bin/lists.asmx

You may be prompted to log onto your SharePoint site when do perform this action.

6) Click on "Go" and the Add Web Reference Dialog should display that it found one service and display you some available operations.

7) Click on "Add Reference"

8) Now you should end up with a new Web Reference Node in the Solution Explorer and your actual Web Reference which may have a funny name like "com.mysite.sharepoint"

9) Right click on the Web Reference and rename it to something simple like "SharePoint", this is what we will use to reference the web service in code.

10) Right click on the Web Reference and select "Properties" and change the "URL Behavior" to "dynamic"

This will add a "app.config" to the project and populate an appSettings item in the config file so that the URL is dynamically loaded from the "app.config" file and not hard coded into the source of the proxy stub that was created.

xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="GetListItems.Sharepoint.Lists" value="http://sharepoint.mysite.com/Test/_vti_bin/lists.asmx"/>
</appSettings>
</configuration>

11) Open the Class1.cs file in the editor and enter the following:

using System;
using System.Net;
using System.Xml;

namespace GetListItems
{
///
/// Summary description for Class1.
///
class Class1
{
///
/// The main entry point for the application.
///
[STAThread]
static void Main(string[] args)
{
string Username="UserName";
string Password="Password";
string Domain="Domain";
string ListName = "ListName";

Sharepoint.Lists ListsService = new Sharepoint.Lists();
ListsService.Credentials = new NetworkCredential(Username, Password, Domain);

// Create a new XML document to hold the updates we are going to perform
XmlDocument doc = new XmlDocument();
XmlElement updates = doc.CreateElement("Batch");
updates.SetAttribute("OnError", "Continue");

// We need to Create a Method Tag for each row we are going to update.
XmlElement UpdatesMethod = doc.CreateElement("Method");
UpdatesMethod.SetAttribute("ID", "1");
UpdatesMethod.SetAttribute("Cmd", "Update");
updates.AppendChild(UpdatesMethod);

// We need to update a particular row based on its internal ID.

XmlElement UpdatesField1 = doc.CreateElement("Field");
UpdatesField1.SetAttribute("Name", "ID"); // Which record to update
UpdatesField1.InnerText = "1"; // is defined here
UpdatesMethod.AppendChild(UpdatesField1);

// We are going to update the field called "Status"

XmlElement UpdatesField2 = doc.CreateElement("Field");
UpdatesField2.SetAttribute("Name", "Status"); // Which field to update
UpdatesField2.InnerText = "Status is OK"; // The actual new value
UpdatesMethod.AppendChild(UpdatesField2);

// Call the web service to update the list items
XmlNode Result = ListsService.UpdateListItems(ListName, updates);

ListsService.Dispose();

Console.WriteLine("The record has been updated!");

// Sleep for a moment so we can see the results
System.Threading.Thread.Sleep(5000);
}
}
}

Make sure you populate the Username, Password, Domain, and ListName variables above. You also need to make sure that the field “Status” exists in the particular list that you are updating. If it does not you will need to change it to a field that does exist.

For some sample code that will allow you to display the attribute names in a list see - /archive/2005/08/10/197.aspx

The XmlNode called Result should be parsed to locate errors that may have occurred during the update.

Tuesday, 17 February 2009

Javascript: Bubble Sorting

Found an interesting article and compact js file to handle dynamic sorting in tables.

Very cool and works flawlessly.

http://www.the-art-of-web.com/javascript/oopsort/

Monday, 2 February 2009

WSS3.0: Deploy Master Pages to Subsite

Was trying to find a way to deploy changes to my master page to subsites and read about creating a feature on Heather Solomons site.

But after further digging around, I found a nicely written solution by Stramit on codeplex.

If you download the non-source v1.1 release, there is a flaw in the batch install and i was scratching my head as to why i'm not seeing the link everyone else was under site settings.

Trick is to download the source version and then read the thread below to fill out the gaps.

http://www.codeplex.com/SPMasterPicker/Thread/View.aspx?ThreadId=43375

Once the install complete, the tool works a charm, thanks Stramit.

Friday, 23 January 2009

WSS3.0: Default Features List

Windows SharePoint Services v3 Features:
33 Features in WSS v3

* AdminLinks
* AnnouncementsList
* BasicWebParts
* ContactsList
* ContentLightup
* ContentTypeSettings
* ctypes
* CustomList
* DataSourceLibrary
* DiscussionsList



* DocumentLibrary
* EventsList
* fields
* GanttTasksList
* GridList
* IssuesList
* IssueTrackingWorkflow
* LinksList
* MobilityRedirect
* NoCodeWorkflowLibrary
* PictureLibrary



* SiteSettings
* SPSearchFeature
* SurveysList
* TasksList
* TeamCollab
* UpgradeLinks
* WebPageLibrary
* WikiWelcome
* WorkflowHistoryList
* WorkflowProcessList
* XmlFormLibrary

Microsoft Office SharePoint Services 2007 Features:
107 Features Added in MOSS 2007*

* AddDashboard
* Analytics
* AnalyticsLinks
* BaseSite
* BaseSiteStapling
* BaseWeb
* BaseWebApplication
* BDCAdminUILinks
* BDR
* BizAppsCTypes
* BizAppsFields
* BizAppsListTemplates
* BizAppsSiteTemplates
* BulkWorkflow
* BulkWorkflowTimerJob
* DataConnectionLibrary
* DataConnectionLibraryStapling
* DeploymentLinks
* DMContentTypeSettings
* EawfSite
* EawfWeb
* EnhancedHtmlEditing
* ExcelServer
* ExcelServerSite
* ExcelServerWebApplication
* ExpirationWorkflow
* FeaturePushdown
* GlobalWebParts
* GradualUpgrade
* Hold
* ipfsAdminLinks
* IPFSAdminWeb
* IPFSDocumentConversion
* IPFSSiteFeatures
* IPFSWebFeatures
* LegacyDocumentLibrary



* ListTargeting
* LocalSiteDirectoryControl
* LocalSiteDirectoryMetaData
* LocalSiteDirectorySettingsLink
* MasterSiteDirectoryControl
* MigrationLinks
* MySite
* MySiteBlog
* MySiteCleanup
* MySiteHost
* MySiteLayouts
* MySiteNavigation
* MySiteQuickLaunch
* Navigation
* NavigationProperties
* OffWFCommon
* OSearchBasicFeature
* OSearchCentralAdminLinks
* OSearchEnhancedFeature
* OSearchPortalAdminLinks
* OSearchSRPAdminLinks
* OsrvLinks
* OsrvTasks
* OssNavigation
* OSSSearchSearchCenterUrlFeature
* OSSSearchSearchCenterUrlSiteFeature
* PageConverters
* PortalLayouts
* PremiumRootSite
* PremiumRootSiteStapling
* PremiumSite
* PremiumSiteStapling
* PremiumWeb
* PremiumWebApplication
* ProfileSynch
* Publishing



* PublishingLayouts
* PublishingPrerequisites
* PublishingResources
* PublishingSite
* PublishingStapling
* PublishingWeb
* RecordsManagement
* RedirectPageContentTypeBinding
* RelatedLinksScopeSettingsLink
* ReportCenterCreation
* ReportCenterSampleData
* Reporting
* ReportListTemplate
* ReviewWorkflows
* SearchAndProcess
* SearchWebParts
* SharedServices
* SignaturesWorkflow
* SitesList
* SkuUpgradeLinks
* SlideLibrary
* SlideLibraryActivation
* SpellChecking
* SPSDisco
* SpsSsoLinks
* SRPProfileAdmin
* StapledWorkflows
* TranslationWorkflow
* TransMgmtFunc
* TransMgmtLib
* UpgradeOnlyFile
* UserMigrator
* ViewFormPagesLockDown
* WebPartAdderGroups

* Two additional features are installed when you upgrade from MOSS 2007 Beta 2 to MOSS Beta 2 Technical Refresh: PublishingB2TRHop2SiteFilesUpgrade & PublishingB2TRSiteFilesUpgrade. These two Features, as their names imply, are used to upgrade some of the publishing files from Beta 2 to Beta 2 Technical Refresh. This also explains why you may have experienced some problems with your existing Publishing sites created in Beta 2 after upgrading to Beta 2 Technical Refresh, as outlined in this post. Because they are upgrade Features, and not likely to be present in the RTM release of MOSS 2007, I am not including them in the count.

Tuesday, 20 January 2009

WSS3.0: Search Scope not showing up

The scenario you've described is completely possible. It will take a few steps, and I'm happy to walk you through them.

For others reading this thread, when beginning an upgrade from WSS 3.0 to Search Server, your best bet is to follow along with the steps in the document "Upgrade to Search Server 2008 from Windows SharePoint Services 3.0"

In that doc, in the section titled "Activate features for Web applications carried over to Search Server", ensure you've followed these steps:

After you install Search Server over Windows SharePoint Services, you must activate features for the Windows SharePoint Services Web applications that were carried over to Search Server. Use the following procedure to activate features for these Web applications.

To activate features for Web applications carried over to Search Server

  1. From the Central Administration Web site, click Application Management.
  2. On the Application Management page, under SharePoint Web Application Management, click Manage Web application features.
  3. On the Manage Web Application Features page, click a Web application.
  4. Next to the description for Office Server Enterprise Search, click Activate.
  5. Next to the description for Office Server Site Search, click Activate.
  6. Repeat steps 3 through 5 for each Web application listed on the Manage Web Application Features page.

Reading this document again, I've noticed that there's a key step missing in order to make your legacy search boxes take advantage the new Search Center experience. I'll request the document be updated to include the following steps.

For each WSS Site Colleciton that existed prior to the upgrade, complete these steps:

1. As a site collection administrator, click on "Site Actions > Site Settings".

2. There will be some new links in the Site Collection Administration column which have appeared as a result of activating the features. Click on "Search Settings"

3. (Now I admit that this page is not intuitive. Just take my word here for what it does...)

There are two radio buttons. Select the one called "Use Custom Scopes".

In the text box, type in the address of your Search Center. The exmple given on that page might be a little misleading. If your the new Search Server Search Center query page is http://[servername]:[port]/default.aspx and the results page is http://[servername]:[port]/resutls.aspx, you can just type in http://[servername]:[port]

Now, if you navigate to a page in your original WSS Site, you should see the following changes:

1. The Scopes Dropdown now includes "All Sites". (You can add more scopes by using the Search Scopes link which is directly below "Search Settings" in Site Collection Administration)

2. When you type in a query, it should now show the results in the Search Center's results.aspx page.


REF: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3020163&SiteID=17

Friday, 16 January 2009

WSS3.0: Viewing search scopes

/_layouts/viewscopes.aspx?mode=site

Thursday, 8 January 2009

Sysadmin: Free Busy Http Request

http://[exchange server]/public/?cmd=freebusy&start=2009-01-08T07:00:00&end=2009-01-08T17:00:00&interval=30&u=SMTP:[email address]

Output:

<a:response xmlns:a="WM">
<a:recipients>
<a:item>
<a:displayname>All Attendees</a:displayname>
<a:type>1</a:type>
<a:fbdata>00000000000020010030</a:fbdata>
</a:item>
<a:item>
<a:displayname>Joe Blogs</a:displayname>
<a:email type="SMTP">jb@jb.com.au</a:email>
<a:type>1</a:type>
<a:fbdata>00000000000020010030</a:fbdata>
</a:item>
</a:recipients>
</a:response>

Response results are broken into half hour timeslots from 7 AM to 5 PM.
These half hour slots return a single integer.

0 means Free
1 means Tentative
2 means Busy
3 means Out of Office
4 means Unable to find you in exchange dude!

Sunday, 4 January 2009

Sysadmin: Standby System using command line

In the run window type:

%windir%\System32\rundll32.exe powrprof.dll,SetSuspendState