Posts

.NET Weblogs @ ASP.NET

.NET Weblogs @ ASP.NET - good weblog site with many bloggers. Of interest is Datagrid Girl - using the datagrid in ASP.NET

Google Toolbar 2.0

Google Toolbar 2.0 is no longer beta: http://toolbar.google.com/ Features: Search the web with Google from any site New! Eliminate pop-up ads New! Fill in forms with one click New! Link a weblog to the page you're visiting New! Restrict your search to pages located in a specific country Search just within the pages of a site Highlight search terms on a page

VBScript - Set Homepage (MSIE) / Add Notepad to Send To

The following will set up your homepage (in Internet Explorer) via a VBScript file. Create a blank text file called 'sethome.vbs'. Running it will change your default home page. Useful for setting the home page via a login script (or after some spyware may have changed your homepage). Set WSHShell = WScript.CreateObject("WScript.Shell") ' home page URL StartPage = "http://www.google.co.uk" WSHShell.RegWrite "HKLM\Software\Microsoft\Internet Explorer\Main\Start Page", StartPage WSHShell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", StartPage This code will add notepad to the Send To menu (when you right click a file). Create a new file called 'sendtonotepad.vbs', containing the following code. Set WSHShell = WScript.CreateObject("WScript.Shell") Set oFSO = WScript.CreateObject("Scripting.FileSystemObject") sWinDir = oFSO.GetSpecialFolder(WindowsFolder) sSendTo = WSHShell.Special...

Overflow PRE tag (HTML & CSS)

Text doesn't wrap with the <pre> tag, so you need to scroll horizontally if there is a lot of text on one line: Nulla neque diam, accumsan nec, egestas non, facilisis sed, wisi. Donec lacinia vestibulum arcu. Suspendisse ligula. Donec tortor. Maecenas pharetra eros at odio. Morbi feugiat tempus orci. Cras vitae tellus. Sed congue nonummy magna. In sed neque id nisl tempus congue. Duis varius egestas tellus. Suspendisse potenti. Nunc rhoncus, eros eget malesuada rhoncus, mi purus pharetra eros, sit amet porta lectus tortor ac erat. In hac habitasse platea dictumst. However, if you wrap it as follows <pre style="overflow: auto; width: 100%">Text</pre> it adds scroll bars when needed: Nulla neque diam, accumsan nec, egestas non, facilisis sed, wisi. Donec lacinia vestibulum arcu. Suspendisse ligula. Donec tortor. Maecenas pharetra eros at odio. Morbi feugiat tempus orci. Cras vitae tellus. Sed congue nonummy magna. In sed neque id nisl tem...

File Functions (JScript):

Various JScript functions for manipulating files: They should all work whichever format you use for the folder (c:\webroot\folder\subfolder\ or /folder/subfolder/) Get files (returned as enumerator): /* sFolder = which folder (e.g. '/folder/subfolder/', 'c:\webroot\folder\subfolder\') return enumerator of files */ function getFiles(sFolder){ // create filesystemobject var oFSO = Server.CreateObject("Scripting.FileSystemObject") // get folder object try{ var oFolder = oFSO.getFolder((sFolder.indexOf("/")==-1)?sFolder:Server.MapPath(sFolder)) }catch(e){ // if error occurs return blank enumerator return new Enumerator() } // create enumerator for files var eFiles = new Enumerator(oFolder.Files) // return files list return eFiles } Get file name: /* sPTF = path to file, bExt = include extension, default yes returns filename as string */ function getFileName(sPTF,bExt){ // new method using filesystemobject if(bExt!=false) bExt = tr...

SQL: Date Searching

Just some useful tips for searching on date fields (Microsoft SQL Server 2000+): You can use the LIKE operator to do a search: SELECT * FROM [tablename] WHERE [datecolumn] LIKE '%Aug%2003%' This would match everything that had August 2003 in datecolumn e.g. August 12 2003, August 18 2003 The other way is to use DATEPART as follows: SELECT * FROM [tablename] WHERE DATEPART(month,[datecolumn]) = 8 AND DATEPART(year,[datecolumn]) = 2003 The final way is to use MONTH and YEAR : SELECT * FROM [tablename] WHERE MONTH([datecolumn]) = 8 AND YEAR([datecolumn]) = 2003 N.B. If you use DATEPART , MONTH , or YEAR , the supplied value has to be numeric (8 instead of August)

Javascript: Remove Items from Array

I required some javascript for removing an item (or series of items) from an array. Thankfully, I found out how to do it from this thread in Google Groups. e.g. (paste into HTML document): <script language="javascript"> // this is the original array var theArray = [17,2,5,675]; // these are the items I wish to remove from the array var toRemove = [17,2]; // it can be done with one item only as well // var toRemove = 5; // adding it as a prototype object enables it to be used from any array Array.prototype.removeItems = function(itemsToRemove) { if (!/Array/.test(itemsToRemove.constructor)) { itemsToRemove = [ itemsToRemove ]; } var j; for (var i = 0; i < itemsToRemove.length; i++) { j = 0; while (j < this.length) { if (this[j] == itemsToRemove[i]) { this.splice(j, 1); } else { j++; } } } } theArray.removeItems(toRemove); alert(theArray); ...