by Stian

Phishing/Spam: iTunes Store -Thank you for your purchase

Please be aware of the following iTunes Store scam e-mail circulating these days.
The e-mail should be deleted and requires no other actions from you.

 

From: iTunes Store <itunestore.int@apple.com>
Subject: Thank you for your purchase

Dear customer,

This is an automated reply, but your Apple ID was just used to download Football Manager Handheld 2014 from the App Store on a computer or device that had not previously been associated with that Apple ID.

Order Number: QAPPCCVW21RCSW
Order total: 9.35 ?

If you initiated this download, you can disregard this email. It was only sent to alert you in case you did not initiate the download yourself.
If you did not initiate this download, we recommend that you go to iTunes Payment Cancellation Form to change your password, then
See Apple ID: Tips for protecting the security of your account for further assistance.

How to resume Payment Cancellation Form iTunes Store downloads

http://support.apple.com/kb/QAPPCCVW21HDST/Cancel

Please do not reply to this email. Thank you for your patience.
Sincerely,
iTunes Store Customer Support

http://www.apple.com/support/itunes/

——————————————————————-
Apple ID : yourÉemail.com
Lang_Country : en_UK
Product : iTunes Store
Support Subject : iTunes Store
Sub Issue : Connecting to iTunes Store with computer
GCRM Case ID : QAPPCCVW21HDST
See additional info below
What device did you use to connect to the store? Windows computer (PC)
Choose the iTunes Store or App Store for your country: United Kingdom
——————————————————————-

 

 

by Andreas

Selenium – Working with dynamic ASP.NET controls

Selenium LogoI recently had to find a replacement for our extensive Watin UI test framework. The reason being problems as a result of the IE11 release, and that Watin seems to have been abandonded in April 2011.

The choice landed on Selenium, which seems to be the de facto standard these days. It allows you to test in a variety of browsers, and is very much alive and kicking. There’s a .NET web driver available as a NuGet package, which makes it very easy to get started. But this isn’t a post about how great (or not?) Selenium is, it’s just a tip for those who’s using it for ASP.NET projects and came across the same annoyance as I did.

Selenium doesn’t handle dynamic ASP.NET controlId’s very well. It says in the docs that they recommend using static id’s, but seriously.. For projects before ClientIdMode was supported (< 4.0) this simply wasn’t an option. And should we go through thousands of lines of code and change this? I think not.

The solution is using XPath. Which, in Selenium’s defence, is supported. But it’s ugly, compared to using RegEx which was supported by Watin. Take the following example:

    <tr>
        <td>
            <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
        </td>
    </tr>

 

To reference this textbox control, Selenium out-of-the-box requires this:

IWebElement e = driver.FindElement(By.XPath("//input[@id[substring(.,string-length()-7)='txtEmail']]"));

 

That’s not pretty. And you have to calculate the length of the controlId, take zero base into consideration (8 minus 1 = 7) and you will hopefully get a working reference. My preferred solution would be to add an extension to the By class, like By.RegEx() or something. But it’s a static class and extension methods require you to create an instance of it, so I had to scrap that idea (something for the next version of C#, Microsoft??)

My second best solution was a set of helper methods to generate the ugly XPath string. I’ve implemented a couple of options, where one get’s a reference without taking the type of control into consideration while the other allows you to look specifically for a textbox (input).

    public static class SeleniumTools
    {

        public static string GetXPath(string controlId)
        {
            return GetXPath(controlId, "*");
        }

        public static string GetXPathForTextBox(string controlId)
        {
            return GetXPath(controlId, "input");
        }

        private static string GetXPath(string controlId, string controlType)
        {
            return "//" + controlType + "[@id[substring(.,string-length()-" + (controlId.Length - 1) + ")='" + controlId + "']]";
        }
    }

 

At least this makes it a bit easier to read, and you don’t have to work out the XPath string manually:

IWebElement e = driver.FindElement(By.XPath(SeleniumTools.GetXPath("txtEmail")));
by Aage Andre

BSOD – process1_initialization_failed

After an afformentioned power-loss, one of the guest-vms started BSOD’ing during boot. Safe mode was no go, and only recovery worked.

Found a tip:

- Copy ‘C:WindowsSystem32CodeIntegritybootcat.cache’ from a working, similar server (2008R2 in this case) to a cd or usb-drive.
- Since this was a Hyper-V guest I created a ISO with the file, using ImgBurn, and mounted the iso inside the guest, while in recovery mode.
- Delete the original bootcat.cache from the system, and copy the working one you got from the other server.
- Reboot.

by Aage Andre

Windows Server 2012R2 reboot loop

One of our hosts ran into a reboot loop after an unplanned shutdown(also known as powerloss). When booting again, the server went straight from booting to shutting down services and rebooting.

Windows update is often the problem when boot-problems occur in my experience. So, boot into recovery mode and command prompt, and remove the file C.WindowsWinSXSpending.xml.

Reboot the server and no updates messing with your host during boot.

 

by Stian

Check if element is hidden with jQuery

 

Expert solutionJust another quick jQuery help post; how can I check if an element is visible or hidden using jQuery?

To check this for a single element, you can write:

// Checks for display:[none|block], ignores visible:[true|false]
$(element).is(":visible")

 

You can also have a selector which gives you all hidden elements:

// Matches all elements that are hidden
$('element:hidden')

 

or of course all visible elements:

// Matches all elements that are visible.
$('element:visible')
by Joakim

Using WinMerge as the default diff/merge tool in Visual Studio 2012/2013

Updated: The procedure described below also works for Visual Studio 2013!

I found the default diff/merge tool in Visual Studio 2012 to be a huge improvement over previous versions, as now you are actually able to see what has changed quite easily.

vs12-compare-1

But that being said, I still prefer to use WinMerge as the default diff/merge tool since it has more features. Another nice feature of WinMerge is the possibility to integrate it into Windows Explorer which allows me to diff files (and folders) on my hard drive.

So how do you make WinMerge the default diff/merge tool in Visual Studio?

Go into “Tools –> Options –> Source Control –> Visual Studio Team Foundation Server”, click on “Configure User Tools …”, and add new commands for the “Compare” and “Merge” operations.

vs12-compare-3

vs12-compare-4

Values for the compare command;
Extension: .* (meaning all files)
Operation: Compare
Command: C:Program Files (x86)WinMergeWinMergeU.exe (the path to where WinMergeU.exe is located)
Arguments: /e /u /wl /dl %6 /dr %7 %1 %2 (the arguments for WinMerge, I’ll explain them in detail further down)

Values for the merge command;
Extension: .*
Operation: Merge
Command: C:Program Files (x86)WinMergeWinMergeU.exe
Arguments: /e /u /wl /dl %6 /dr %7 %1 %2 %4

After you add these two commands, right-clicking a file in Visual Studio and selecting “Compare…” should result in the two files being opened and compared in WinMerge. Should you want to go back to using Visual Studio’s own diff/merge tool, you just remove the two commands again.

vs12-compare-2

So what do the values used in the arguments field in the two commands actually mean?

Values starting with a forward slash (/) are WinMerge command-line parameters. The full list of possible parameters can be found here. But I’ll list the ones I use (not all of them are necessary, you may remove some or add others as you prefer):

/e –> Enables you to close WinMerge with a single Esc key press
/u –> Prevents WinMerge from adding either path (left or right) to the Most Recently Used (MRU) list
/wl –> Opens the left side as read-only
/dl –> Specifies a description in the left side title bar
/dr –> Specifies a description in the right side title bar

Values starting with a percentage sign (%) are provided by Visual Studio as input for the WinMerge parameters. You can see what they stand for by clicking the “play” button behind the arguments field when you create the command, but I’ll list them here as well (I’ve greyed out those I don’t use):

%1 –> Original file
%2 –> Modified file
%3 –> Base file
%4 –> Merged file
%5 –> Diff command-line options
%6 –> Original file label
%7 –> Modified file label
%8 –> Base file label
%9 –> Merged file label

WinMerge can be downloaded the from here.

by Joakim

Detecting Browser Types and Browser Capabilities in Asp.Net

The following helper class allows you to detect browser types and browser capabilities in Asp.Net. It works in both MVC-controllers/views and WebAPI-controllers (and I would think it should work with WebForms as well).

using System;
using System.Collections;
using System.Collections.Specialized;
using System.Web;
using System.Web.Configuration;

namespace MyProject.Helpers
{
    public static class BrowserInfoHelper
    {
        public static string GetUserAgent()
        {
            return HttpContext.Current.Request.UserAgent;
        }

        public static HttpBrowserCapabilities GetCapabilities()
        {
            var capabilities = new HttpBrowserCapabilities();

            var hashtable = new Hashtable(180, StringComparer.OrdinalIgnoreCase);
            hashtable[string.Empty] = GetUserAgent();
            capabilities.Capabilities = hashtable;

            var capabilitiesFactory = new BrowserCapabilitiesFactory();
            var headers = new NameValueCollection();
            capabilitiesFactory.ConfigureBrowserCapabilities(headers, capabilities);
            capabilitiesFactory.ConfigureCustomCapabilities(headers, capabilities);

            return capabilities;
        }
    }
}

 

Then use it, for example in an MVC-view, like so;

@MyProject.Helpers
@{
    var browserCapabilities = BrowserInfoHelper.GetCapabilities();
    var browserIsOldIE = browserCapabilities.Browser.Equals("IE", StringComparison.InvariantCultureIgnoreCase) && browserCapabilities.MajorVersion < 9;
}
@if (browserIsOldIE)
{
    <div>Please upgrade your browser!</div>
}
by Andreas

IE 11 / Windows 8.1 update killed my local sites

imageAfter upgrading to Internet Explorer 11 (included in the recent Windows 8.1 update) my local IIS hosted web applications suddenly died. But only in Internet Explorer – the other browsers (Safari, Chrome and Firefox) were unaffected.

After some research I found out that IE 11 comes with a brand new technology called AppContainer. It’s a protection mechanism that blocks Read and Write access to most of your system, including your IIS hosted sites.

 

There are several ways of getting around this, but I simply turned off “Enhanced Protection Mode” under IE 11 Internet Options. I use Chrome for my daily browsing anyway, and IE is just for verifying browser compatibility of my applications. Remember to restart your browser afterwards.

image

by Njål

File Format/Extension CSV

 

imageHere is a CSV(comma separated values) list I put together with over 10500 file formats and descriptions.

I got the content from various websites – by making a small C# program that screenscraped the content that I wanted to collect.

Download the csv file here.

If you want to include this list directly in your c# code – then grab this this file.

by Aage Andre

Mikrotik RouterOS – Conditional DNS-forward

One of the big pains of having a complete network of L2TP/IPSec-devices is that you have to have DNS servers at each site, or run a central DNS-server which could be slow to reach and the users start complaining about slow internet.
This is a simple config-script to allow you to run your central DNS only on internal domains, and everything else on.. well, any DNS you want.

Notes:
The script creates a new pre-routing connection-mark, checking if the DNS-lookup on the router, port 53 is looking for something with “yourdomain.local”. When it is, it DST-NATs and forwards the packet to your internal DNS without doing anymore processing.

It assumes you use the router/gateway as DNS-server with remote requests enabled in DNS-setup.

 

# The domain you want to be able to look up
:global DOMAIN
yourdomain.local  

# This is needed because the script won't allow a variable and a dash.. so no "$DOMAIN-forward"
:global CONMARK yourdomain.local-forward

# The LAN ip of your router
:global ROUTER 192.168.0.1

# The DNS-server where you look up "yourdomain.local"
:global DNSSERVER
1.1.1.10

 

/ip firewall layer7-protocol add name=$DOMAIN regexp=$DOMAIN
/ip firewall mangle add chain=prerouting dst-address=$ROUTER layer7-protocol=$DOMAIN action=mark-connection new-connection-mark=$CONMARK protocol=tcp dst-port=53
/ip firewall mangle add chain=prerouting dst-address=$ROUTER
layer7-protocol=$DOMAIN action=mark-connection new-connection-mark=$CONMARK protocol=udp dst-port=53
/ip firewall nat add action=dst-nat chain=dstnat
connection-mark=$CONMARK to-addresses=$DNSSERVER
/ip firewall nat add
action=masquerade chain=srcnat connection-mark=$CONMARK