Skip to main content

Posts

Showing posts from 2010

Setup Passive FTP on Windows 2003 and IIS6

Two key items need to be completed for this:Configure FTP to use a specific range of passive ports so only a short range need be allowed through Windows Firewall.Setup the passive FTP port range to work through Windows Firewall.Configure FTP to use a restricted range of passive FTP portsBy default passive FTP under IIS 6 will use a port in the range 1024 – 65535.
When setting your own range of ports the range must be within 5001 – 65535.Enable Direct Metabase Edit in IIS
1. Open the IIS Microsoft Management Console (MMC).
2. Right-click on the Local Computer node.
3. Select Properties.
4. Make sure the Enable Direct Metabase Edit checkbox is checked.Configure PassivePortRange via ADSUTIL script
1. Click Start, click Run, type cmd, and then click OK.
2. Set the directory to Inetpub\AdminScripts. Depending on your system configuration this can either be achieved by entering cd Inetpub\AdminScripts and then pressing ENTER or cd C:\Inetpub\AdminScripts and pressing ENTER or locate the path for …

AJAX jQuery GET caching

It seems the HTTP specification allows anything in a GET request chain to cache the results of a request.  Internet Explorer has apparently been well known for this but now Firefox has started to exhibit the same behaviour.
If using jQuery ajax GET requests you need to do this to prevent it:
    $.ajaxSetup({cache: false});
In addition, to ensure the results are definitely not cached a random string can be added to the end of the request URL e.g.
    var randomNumber = Math.floor(Math.random() * 1000);
    var url = targetUrl + '?rnd=' + randomNumber;

Convert Wordpress to Blogger format

Having tried out Wordpress on a cheap host the experience was just too slow so now moving back to Blogger. If for any reason you need to move from Wordpress to Blogger you will need to convert the XML export file.

For Small Blogs
Wordpress2Blogger web service provides a simple Wordpress to Blogger conversion. Login into your Wordpress blog then goto "Manage" or "Tools" tab and export your blog as an XML file.

Now upload the file to Wordpress2Blogger online service to make it Blogger compatible. Download the resultant file and import it into Blogger via the Blogger dashboard. Your Wordpress posts will be imported as drafts, from there you can check and publish then as necessary. This method works for export files up to 1Mb.

For Larger Blogs
Larger blogs require a different method. Take a look at the Google Blog Converter project. As pointed by Google OpenSource blog this new Open Source project provides the ability to easily move blog posts and comments from service t…

Windows 7 Shortcut Keys

Windows + ↑ (Up Arrow) – Maximize window
Windows + ← (Left Arrow) – Snap window to left side covering half of desktop space. Continue pressing the keyboard shortcut will rotate the window between snap to left, snap to right and restore to normal position.
Windows + → (Right Arrow) – Snap window to right side covering half of desktop space. Continue pressing the keyboard shortcut will rotate the window between snap to left, snap to right and restore to normal position.
Windows + ↓ (Down Arrow) – Minimize the window. Restore to normal size and position if the window is currently maximized.
Windows + Home – Clear all but the active window.
Windows + Space – All windows become transparent so you can see through to the desktop.
Windows + Shift + ← (Left Arrow) – Move the active window to the adjacent monitor on the left for dual or multiple monitors setup.
Windows + Shift + → (Right Arrow) – Move the active window to the adjacent monitor on the right for dual or multiple monitors setup.
Wi…

SQL Server 2005 Error When Creating SQL Agent Job

I am running SQL Server 2005 Workgroup Edition, I get the following error when creating a SQL Server Agent Job:
Unable to cast object of type 'Microsoft.SqlServer.Management.Smo.SimpleObjectKey' to type 'Microsoft.SqlServer.Management.Smo.Agent.JobObjectKey'. (Microsoft.SqlServer.Smo)Not good!
The error can have a number of causes. Solutions include:
Installing SQL Server 2005 SP2 (claimed by a number of individuals to work).If you are accessing the SQL Server across a network, logon to the server using remote desktop or similar and attempt to create the job locally.

Environment SpecialFolder directory paths

The Environment.SpecialFolder enumeration can be used to obtain the full path to system special folders.
The enumeration includes:

ApplicationData
Common repository for application-specific data for the current roaming user.
CommonApplicationData
Common repository for application-specific data that is used by all users.
LocalApplicationData
Common repository for application-specific data that is used by the current, non-roaming user.
Cookies
Common repository for Internet cookies.
Desktop
The logical Desktop rather than the physical file system location.
DesktopDirectory
The directory used to physically store file objects on the desktop.
Favorites
Common repository for the user's favourite items.
History
Common repository for Internet history items.
InternetCache
Temporary Internet files folder.

Programs
The directory that contains the user's program groups.
MyComputer
The My Computer folder.
n.b.
The MyComputer constant always yields the empty string ("") because no p…

HTC Phone Comparison

I currently have an HTC Touch Diamond and have been looking at changing to an Android phone. A quick comparison of the main options of HTC Desire, HTC Legend and HTC Wildfire.
Touch DiamondDesire Legend WildfireCPU Speed528 MHz1 GHz600 MHz528 MHzCPU TypeQualcomm® MSM7201ASnapdragonQualcomm MSM7227Qualcomm MSM7225Width51 mm60 mm56.3 mm60.4 mmHeight102 mm119 mm112 mm106.75 mmDepth11.35 mm11.9 mm11.5 mm12.9 mmOSWindows 6.1Android 2.1Android 2.1Android 2.1ControlTouchFLO 3DHTC SenseHTC SenseHTC SenseROM256 Mb512 Mb512 Mb512 MbRAM192 Mb576Mb384 Mb384 MbInternal Storage4GbAdditional StorageMicro SD up to 32 GbMicro SD up to 32 GbMicro SD up to 32 GbWeight110 g135 g126 g118 gDisplay2.8 in TFT-LCD VGA3.7 in AMOLED WVGA3.2 in AMOLED HVGA3.2 in QVGANetworkTri-bandQuad-bandQuad-bandQuad-bandGPSGPS & GPS-AGPSGPSGPSBluetooth2.0 with EDR2.1 with EDR2.1 with EDR2.1 with EDRWi-FiIEEE 802.11 b/gIEEE 802.11 b/gIEEE 802.11 b/gIEEE 802.11 b/g3G7.2 Mbps7.2 Mbps7.2 MbpsGPRS114 Kbps114 Kbps114 KbpsEDGE56…

Orange Mobile Contract Renewal - Beware

For any existing Orange customers hoping to obtain a competitive renewal on their Orange contract, beware!
A number of phone companies commit to providing the same deals to their existing as they use to lock in new customers. Some, T-Mobile for one, even claim to offer better deals to their existing customers.
Orange used to be fair handed on contract renewals and would assess past usage, upgrade phones and commitment to future usage on a new contract. This is no longer the case. Their policy is now to base all new deals (both contract and phone) on the past usage, regardless of the new contract value. In addition to this certain phones are flagged so Orange reps are unable to offer competitive deals to existing customers – this applies to the most popular handsets.
For a new customer it is possible to obtain an HTC Desire from almost any network for free on a £30 a month contract, this includes Orange on the rare occasions they have any in stock. My mobile usage is average but not he…

Apple iPhone and iPod WebClip icons

The iPhone and iPod Touch devices allow a user to save a WebClip bookmark to a site on their Home Screen.
To specify a bookmark icon for all pages of a web site, place a PNG image named "apple-touch-icon.png" in the root directory of your web site - similar to the "favicon.ico" for site icons.
To override the site bookmark icon on a specific web page, insert a <link> element similar to <link rel="apple-touch-icon" href="/customIcon.png"/> within the <head> element of the page.
The bookmark icon dimensions should be 57x57 pixels. If the icon is a different size it will be scaled and cropped to fit.

Safari will automatically composite the icon with the standard "glassy" overlay so it looks like a built-in iPhone or iPod application.

Programmatically grant user privileges

When installing services, in particular SQL Server, it is a frequent requirement to create a service user and assign certain rights. To assist users during installation it is helpful to gather the required information (e.g. username + password) amd programmatically create the user for them. To achieve this you will need to create the user, assign it to the appropriate groups and grant any specific rights. Granting privileges and impersonation is covered in Corinna John's CodeProject article: http://www.codeproject.com/KB/cs/lsadotnet.aspx
How to add a user to the local system using C#: http://support.microsoft.com/kb/306273
How to add a user to the domain using C#: http://en.csharp-online.net/User_Management_with_Active_Directory%E2%80%94Creating_Users

Compress and de-compress strings in C#

A collection of resources on compressing and encrypting strings in C#.
Microsoft documentation on the System.IO.Compression.GZipStream class:
http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx
Helpful example class utilising GZip:
http://www.csharphelp.com/2007/09/compress-and-decompress-strings-in-c/
The GZipStream class is predominantly used for file compression but can be used efficiently for compressing strings of 300-400 characters or more. Below 300 characters there isn’t any measurable gain from the compression and for particularly short strings the compressed version may in fact be larger.
Class provided by C Sharp Help:
using System.IO.Compression;
using System.Text;
using System.IO;
public static string Compress(string text)
{
    byte[] buffer = Encoding.UTF8.GetBytes(text);
    MemoryStream ms = new MemoryStream();
    using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress, true))����…

Drop Default Constraint

The basic syntax for dropping a constraint is quite simple:
ALTER TABLE {{MYTABLENAME}} DROP CONSTRAINT {{CONSTRAINTNAME}}
The problem comes if you have created unnamed constraints as SQL will have assigned a random name. You need to discover the constraint name before you can drop it.
To discover the constraint name:
SELECT name FROM sysobjects so JOIN sysconstraints sc ON so.id = sc.constid WHERE object_name(so.parent_obj) = '{{MYTABLENAME}}' AND so.xtype = 'D' AND sc.colid = (SELECT colid FROM syscolumns WHERE id = object_id('dbo.{{MYTABLENAME}}') AND name = '{{COLUMNNAME}}')
To discover and drop the constraint:
DECLARE @defname VARCHAR(100), @cmd VARCHAR(1000);
SET @defname = (SELECT name FROM sysobjects so JOIN sysconstraints sc ON so.id = sc.constid WHERE object_name(so.parent_obj) = '{{MYTABLENAME}}' AND so.xtype = 'D' AND sc.colid = (SELECT colid FROM syscolumns WHERE id = object_id('dbo.{{MYTABLENAME}}') A…

Modify local security policy to grant service rights

Specific rights must be granted to user accounts to allow the account to be used to run as a service. There are a number of possible methods.
Method 1: Grant rights using Group Policy
This can be achieved using group policy: http://support.microsoft.com/kb/256345/
Method 2: Grant rights using Security templates
Similar to method 1 but using Security templates to change the permissions on system services.
   1. Click Start, click Run, and then type MMC.
   2. On the Console menu, click Add/Remove Snap-in.
   3. Click Add.
   4. Select the Security Configuration and Analysis snap-in, and then click Add.
   5. Click Close, and then click OK.
   6. In the MMC, right-click the Security Configuration and Analysis item, and then click Open Database.
   7. Give a name for the database, and then browse to where you would like to store it.
   8. When prompted, select a Security Template to import. For example, the "basicwk.inf" contains values for the standar…

SQL 2005/2008 Ad hoc access to OLE DB provider has been denied

I have a previous post on enabling adhoc access for SQL 2000 (http://blog.bansheetechnologies.co.uk/2009/02/ad-hoc-access-to-ole-db-provider-has.html), SQL 2005 and 2008 are a little different.
SQL 2005/2008 returns the following:
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online. To enable OpenRowset and OpenDatasource:
Launch the "SQL Server 2005 Surface Area Configuration" tool. Click "Surface Area Configuration for Features" Select "Server Name > Database Engine > Ad Hox Remote Queries" Tick "Enable OPENROWSET and OPENDATASOURCE&quo…

Free Port Scanner

Concerned about open ports and security problems.
You can make a start with the free port scanner provided by Security Metrics.
They offer two flavours of scan, either home or business.
Home
Quick Port Scan of 22 ports Immediate resultsSecurity recommendations available via email
Business
For Webmasters, Network Administrators, and Executives - test up to three  servers. Comprehensive
- Port Scan - 65,535 TCP ports & many UDP ports
- Thousands of Vulnerability Assessment tests
- Mail Proxy test for open relays
- Test for hundreds of default username/passwords
- Website html spidering for XSS & other leaks Email notification when the tests are completed Upon authentication you will receive complete vulnerability assessment results

jQuery Lightbox Scripts

jQuery Lightbox Plugin

jQuery lightBox plugin is simple, elegant, unobtrusive, no need extra markup and is used to overlay images on the current page through the power and flexibility of jQuery´s selector.
lightBox is a plugin for jQuery. It was inspired in Lightbox JS by Lokesh Dhakar.Supports: images.
Main site: http://leandrovieira.com/projects/jquery/lightbox/
Fancybox

FancyBox is a tool for displaying images, html content and multi-media in a Mac-style "lightbox" that floats overtop of web page.
It was built using the jQuery library. Licensed under both MIT and GPL licensesSupports: images, HTML, iFrame content
Main site: http://fancybox.net/
Shadowbox

Shadowbox is a web-based media viewer application that supports all of the web's most popular media publishing formats. Shadowbox is written entirely in JavaScript and CSS and is highly customizable. Using Shadowbox, website authors can showcase a wide assortment of media in all major browsers without navi…

Windows 7 Disable UAC

Particularly when using a PC for development purposes the inbuilt user account control (UAC) can be a pain. The following steps will disable UAC completely, the same process can be used to reduce the level of UAC on the system.
Choose "Start" Enter "Action Center" in the search box Press Enter Click "Change User Access Control settings" Move the slide to "Never notify" Click OK Restart the PC

Enable IIS in Windows Vista

In Windows Vista and above all of the available features are installed by default but aren’t necessarily enabled. By default IIS is disabled in Windows Vista, the following steps will allow you to enable the feature.
Open Control Panel Click "Programs" Click "Turn Windows Features on or off" Expand "Internet Information Services" Expand "Web Management Tools" Tick "IIS Management Console" Expand "World Wide Web Services" Expand "Application Development Features" and tick ".NET Extensibility" and ASP.NET Expand "Common Http Features" and tick "Default Document", "HTTP Errors" and "Static Content" Expand "Health and Diagnostics" and tick "HTTP Logging" and "Request Monitor" Expand "Security" and tick "Basic Authentication", "IP Security", "Request Filtering" and "Windows Authentication" Clic…

Exception Types

SystemException
A failed run-time check;used as a base class for other.
AccessException
Failure to access a type member, such as a method or field.
ArgumentException
An argument to a method was invalid.
ArgumentNullException
A null argument was passed to a method that doesn't accept it.
ArgumentOutOfRangeException
Argument value is out of range.
ArithmeticException
Arithmetic over - or underflow has occurred.
ArrayTypeMismatchException
Attempt to store the wrong type of object in an array.
BadImageFormatException
Image is in the wrong format.
CoreException
Base class for exceptions thrown by the runtime.
DivideByZeroException
An attempt was made to divide by zero.
FormatException
The format of an argument is wrong.
IndexOutOfRangeException
An array index is out of bounds.
InvalidCastExpression
An attempt was made to cast to an invalid class.
InvalidOperationException
A method was called at an invalid time.
MissingMemberException
An invalid version of a DLL was accessed.
NotFiniteNu…

Recover a stolen laptop or device with Prey

Very handy open source utility for remotely monitoring your laptop/device in the hope of capturing details of the miscreant!
http://preyproject.com/
Prey helps you locate your missing laptop by sending timed reports with a bunch of information of its whereabouts. This includes the general status of the computer, a list of running programs and active connections, fully-detailed network and wifi information, a screenshot of the running desktop and — in case your laptop has an integrated webcam — a picture of the thief.

Microsoft Leaks Office 2010 Upgrade Plan

Originally posted to the Microsoft partner site and then hastily removed Microsoft have revealed the specifics of their upgrade plans for purchasers of Office 2007 to be able to update to 2010 when it is released.

Original page.

Google cached version.

Original text:
Microsoft Office 2010 Technology Guarantee Program
Sell Office 2007 today and your customer can download Office 2010 free!
How the program works:


Purchase Office 2007—Customer buys qualifying Office 2007 product (with or without a new PC) from an authorized reseller between March 5 – September 30, 2010.

Install and Activate Office 2007—Customer installs and activates Office 2007 by September 30, 2010.

Download Office 2010—Customer simply downloads Office 2010 for free when Office 2010 is available, or orders a DVD for a fee. Customer must request upgrade by October 31, 2010.

Below are some of the Office 2007 products your customer can purchase and activate between March 5 and September 30, 2010 to be eligible for the Office 2010 …

Connect Coldfusion to SQL Server Express

Having recently installed SQL Server Express 2005 on a client server running CFMX 7 I have had to work through the torture of attempting to make the existing SQL Server database driver and then realising it will not work with anything higher than SQL 2000!

The instructions below are based on FusionCube but have been modified for my needs.

These instructions assume you have already install SQL Server Express and Management Studio Express.

Prepare the database server
Open the SQL Server Management StudioClick on the Registered Servers button in the toolbarRight-click the SQL Express server.Select “SQL Server Configuration Manager”If needed, enable the TCP/IP protocol under SQL Server Configuration Manager > SQL Server 2005 Network Configurations > Protocols for SQLEXPRESSDouble-click the TCP/IP protocol to view the properties.Click on the IP Addresses tab and make sure that the TCP Port is set to 1433 for every IP type.Close the configuration manager.Right-click the SQL Express serv…

Good quality icon packs for web and Windows development

Take website screenshot using ASP.NET

Utilising a hidden web browser control it is possible to take a screenshot of any website. The code shown below is based on an article at plentyofcode.com (sorry the site now appears to be offline May 2012) but I have translated it from VB.NET to C# and will work in .NET so theoretically for any Windows or ASP.NET web project.
using System; using System.Drawing; using System.Drawing.Imaging; using System.Windows.Forms; using System.Diagnostics; namespace WebsiteScreenshot { public class GetImage { private int s_Height; private int s_Width; private int f_Height; private int f_Width; private string myURL; public int ScreenHeight { get { return s_Height; } set { s_Height = value; } } public int ScreenWidth { get { return s_Width; } set { s_Width = value; } } public int ImageWidth { get { return f_Width; } set { f_Width = value; } } public int ImageHeight { get { return f_Height; } set { f_Height = value; } } public string Website …

iPad is finally confirmed

Apple’s new all singing all dancing device has been announced!See the live feed here: http://live.gdgt.com/2010/01/27/live-apple-come-see-our-latest-creation-tablet-event-coverage/Here’s what the Apple iPad looks like.Image courtesy of GdGt.com