Blog moving to http://blog.xploiter.com

15 01 2009

This blog will be moving, actually it already has, i’m just keeping the two side by side until the search engines grab a hold of it properly.

Anyways the new URL is:

http://blog.xploiter.com

Pass it around, add comments, use and abuse it and let me know what you want me to cover 🙂

Si





My Photography Website – http://www.simonantony.co.uk

9 01 2009

I’ve developed a new website using asp.net in c# to promote my photography business covering weddings,portraits, parties, events, corporates etc – visit the site and let me know your thoughts:

http://www.simonantony.co.uk





Split SQL Strings

22 12 2008

If you have a need to parse a string array passed in as a variable into say a stored proc, use the following function to split it:

CREATE FUNCTION dbo.fnSplit(
@sInputList VARCHAR(8000) — List of delimited items
, @sDelimiter VARCHAR(8000) = ‘,’ — delimiter that separates items
) RETURNS @List TABLE (item VARCHAR(8000))

BEGIN
DECLARE @sItem VARCHAR(8000)
WHILE CHARINDEX(@sDelimiter,@sInputList,0) 0
BEGIN
SELECT
@sItem=RTRIM(LTRIM(SUBSTRING(@sInputList,1,CHARINDEX(@sDelimiter,@sInputList,0)-1))),
@sInputList=RTRIM(LTRIM(SUBSTRING(@sInputList,CHARINDEX(@sDelimiter,@sInputList,0)+LEN(@sDelimiter),LEN(@sInputList))))

IF LEN(@sItem) > 0
INSERT INTO @List SELECT @sItem
END

IF LEN(@sInputList) > 0
INSERT INTO @List SELECT @sInputList — Put the last item in
RETURN
END
GO
–Test
select * from fnSplit(‘1,22,333,444,,5555,666’, ‘,’)
select * from fnSplit(‘1##22#333##444′,’##’) –note second item has embedded #
select * from fnSplit(‘1 22 333 444 5555 666’, ‘ ‘)

Original Article Here : http://searchwindevelopment.techtarget.com/tip/0,289483,sid8_gci932171,00.html#





Windows Skydrive to upgrade to 25gig online storage!

21 11 2008

If you don’t know, Windows Skydrive is Microsoft’s offering of free online storage – previously it was only 5gig but now they are upping this limit to 25gig, more than likely to bring them in line with other free online storage providers out there (me cynical, nah!)

Anyways I played about with it a few months ago and promptly left it dead for the following reasons:

  • You can only upload a max file size of 50 meg, pretty useless nowadays
  • There are no tools to bulk upload many files so if you have 1000 files to upload, you had to use their upload form which if I recall only allowed 5 files at a time!!!
  • There is no way to map the service to a drive on your system
  • I’m going to keep an eye on this as it’s something I’m looking at seriously as online backup, I’d like the following features implementing which I feel are definitely required in order for it to be taken seriously by users:

  • Remove the max file size restrictions or at least increase it to something usable
  • Provide an API so that developers like us can write upload tools that actually do what we want them to do
  • Give us a better bulk upload experience
  • Automatic sync would be great
  • Possibly built in encryption (although I would encrypt anything I upload to there anyway) – not that I don’t trust you Microsoft, but I don’t!
  • You can read more at the Windows Team Blog HERE

    I’ve also just discovered Windows Live FolderShare – don’t know anything about it yet apart from the fact it’s about to be replaced by Windows Live Sync in December but i’m going to check it out and see how these services complement SkyDrive………………





    Microsoft to offer free malware and other security offerings!!!

    19 11 2008

    Techradar.com has pointed out that Microsoft are to offer free Malware tools to comabat the increasing problem of botnets etc on users PC’s

    Microsoft is getting serious about global security, offering a free anti-malware package code-named Morro that has been specially designed for low cost PCs in developing nations.

    The software will be available in the second half of 2009 and will provide ‘comprehensive protection’ from ‘the majority of online threats’, including viruses, spyware, rootkits and trojans.

    Morro is based on – and will replace – the current Windows Live OneCare subscription service, although it has been architected to use fewer computing resources, making it ideal for low-bandwidth scenarios or less powerful PCs.

    Also destined for the chop is Equipt, Microsoft’s shortlived excursion into consumer software-as-a-service, offering cloud storage of files, updates to Microsoft Office packages and Windows Live OneCare, for an annual cost of £59. Microsoft Equipt launched just one month ago.

    Microsoft vs malware

    Amy Barzdukas, Senior Director at Microsoft, said: “This new, no-cost offering will give us the ability to protect an even greater number of consumers, especially in markets where the growth of new PC purchases is outpaced only by the growth of malware.”

    Morro will deliver the same core protection against malware as Microsoft’s enterprise solutions, but without the additional non-security features found in many consumer security suites, which probably means password managers, identity protection software and online secure storage.

    “By offering basic protection at no charge to the consumer, Microsoft is promoting a safer environment for PCs, service providers and e-commerce itself, since it is through unprotected PCs that the worst threats are introduced to the system as a whole,” said Roger Kay, Founder of Endpoint Technologies Associates.

    Cross-platform support

    Morro will be available as a stand-alone download for Windows XP, Vista and Windows 7. Windows Live OneCare will continue to be sold until June 30, 2009, and all existing subscriptions to it will be honoured.

    Microsoft will end retail sales of Equipt within the next 90 days and halt subscription services in the first half of 2009. The company says that customers who subscribed to this service continue ‘to get value from it’ until the end of their subscription period – October 2009 – and will provide detailed information about ‘customer options’ early next year.

    If those ‘options’ are the same as US users of Equipt received, UK purchasers can expect a free license key to Microsoft Office Home and Student (worth about £70) and possibly even a pro-rated refund, which isn’t a bad deal.

    About time they took it seriously, mind you nowadays i’m using a Mac 🙂





    How to programmatically turn on the Numlock Key

    7 11 2008

    The following code will allow you to turn on the numlock key upon startup. Can’t credit anyone as i’m not sure where it came from but it does work 100%

    using System;
    using System.Runtime.InteropServices;

    class SetNumlockKeyOn
    {
    [StructLayout(LayoutKind.Sequential)]
    public struct INPUT
    {
    internal int type;
    internal short wVk;
    internal short wScan;
    internal int dwFlags;
    internal int time;
    internal IntPtr dwExtraInfo;
    int dummy1;
    int dummy2;
    internal int type1;
    internal short wVk1;
    internal short wScan1;
    internal int dwFlags1;
    internal int time1;
    internal IntPtr dwExtraInfo1;
    int dummy3;
    int dummy4;
    }
    [DllImport(“user32.dll”)]
    static extern int SendInput(uint nInputs, IntPtr pInputs, int cbSize);

    public static void SetNumlockOn()
    {
    const int mouseInpSize = 28;//Hardcoded size of the MOUSEINPUT tag !!!
    INPUT input = new INPUT();
    input.type = 0x01; //INPUT_KEYBOARD
    input.wVk = 0x90; //VK_NUMLOCK
    input.wScan = 0;
    input.dwFlags = 0; //key-down
    input.time = 0;
    input.dwExtraInfo = IntPtr.Zero;

    input.type1 = 0x01;
    input.wVk1 = 0x90;
    input.wScan1 = 0;
    input.dwFlags1 = 2; //key-up
    input.time1 = 0;
    input.dwExtraInfo1 = IntPtr.Zero;

    IntPtr pI = Marshal.AllocHGlobal(mouseInpSize * 2);
    Marshal.StructureToPtr(input, pI, false);
    int result = SendInput(2, pI, mouseInpSize); //Hardcoded size of the MOUSEINPUT tag !!!

    //if (result == 0 || Marshal.GetLastWin32Error() != 0)
    // Console.WriteLine(Marshal.GetLastWin32Error());
    Marshal.FreeHGlobal(pI);
    }
    }





    Deleting elements from XML Documents

    7 11 2008

    If you need to delete either a Node, Element or Attribute from your XML document, try the following code as it actually works!!!

    XML Document Structure

    <?xml version=1.0encoding=utf-8standalone=yes?>
    <!–
    XML Config file–>
    <Tests
    >
    <
    Test>
    <
    ID>47d272cd-877d-4d0f-ad4a-cfa31200d966</ID>
    <
    Object>Obj1</Object>
    <
    TestType>Fail Yes</TestType>
    <
    Command>fail yes</Command>
    <
    Time>202</Time>
    <
    Expiry>0</Expiry>
    </
    Test>
    <
    Test>
    <
    ID>71b211a7-99e4-4041-ada7-2925b6aff46f</ID>
    <
    Object>Obj2</Object>
    <
    TestType>Fail No</TestType>
    <
    Command>fail no</Command>
    <
    Time>243</Time>
    <
    Expiry>0</Expiry>
    </
    Test>
    </
    Tests>

    To delete the element based on the GUID I Use:

    ///
    /// Allows you to delete an element from the XML File
    ///
    /// String GUID ID to remove from the config file
    /// Name of the element to delete
    public void RemoveElement(string elementName, string id)
    {
    System
    .Xml.XmlDocument doc = new System.Xml.XmlDocument();

    doc.Load(filename);

    System.Xml.XmlNodeList list = doc.GetElementsByTagName(Test);

    for (int i = 0; i < list.Count; i++)
    {

    int j = 0;
    for (j = 0; j < list[i].ChildNodes.Count; j++)
    {

    if (list[i].ChildNodes[j].Name.ToUpper() == “ID”)
    break;
    }

    if (j < list[i].ChildNodes.Count && list[i].ChildNodes[0].InnerText == id)
    {
    System
    .Xml.XmlNode parent = list[i].ParentNode;
    parent
    .RemoveChild(list[i]);
    }
    }
    doc
    .Save(filename);
    }

    Another way that i’ve not got around to testing (but which I like) is to use a DataView to suck the XML in, parse using the filter property and then after deleting, re-export as XML:

    DataSet ds = new DataSet();
    ds
    .ReadXml(“xmlAdd file as above”);
    if (ds != null && ds.Tables.Contains(“stickies”))
    {

    DataView dv = new DataView(ds.Tables[“stickies”]);
    dv
    .RowFilter = “id=1”;
    if (dv.Count >= 1)
    {
    dv[
    0].Delete();
    ds
    .AcceptChanges();
    ds
    .WriteXml(“updated.xml”);
    }
    }