Archive

Archive for the ‘Development’ Category

Universal SMS Archiver

May 13, 2016 Leave a comment

Users who have been using Android devices will swear by SMS Backup and Restore to backup their SMS, while iOS users have iTunes backup. While these works, one issue with such software is that you generally do not want to keep or transfer all of your old SMS into the new device.

Introducing Universal SMS Archiver!

  • It is a desktop app that runs on Windows, and has the ability to automatically import your SMS from iTunes and SMS Backup and Restore files.
  • You can also manage the entire list of SMS into a current as well as archived list.
  • It has the ability to export your current sms list into Excel for further processing

image

The latest executable can be downloaded at https://onedrive.live.com/redir?resid=895931B65435BB3D!30467&authkey=!AG-VaHLPBh10qLg&ithint=file%2czip

Source code can be found at https://github.com/kwanann/Hobbies/tree/master/Universal%20SMS%20Archiver

Microsoft Team Foundation Server–Undoing checkout for a workspace that no longer exists

February 2, 2016 1 comment

Every once in a while, you get a request from your developer telling you that they have reformatted their machine and unfortunately there is still one or 2 files inside that workspace that they forgot to checkout

Visual studio comes with tools that allows you to undo checkout. Unfortunately it runs from the CLI

  1. Goto the visual studio folder
    cd “C:\Program Files (x86)\Microsoft Visual Studio 14.0”
  2. List workspaces of the user
    tf workspaces /collection:http://mytfsserver:8080/tfs/defaultcollection /owner:JohnDoe

    Collection: http://mytfsserver:8080/tfs/defaultcollection
    Workspace Owner          Computer  Comment
    ——— ————– ——— ————————————————————————————
    JD-PC JohnDoe JD-PC
    JD-PC2     JohnDoe JD-PC2
    JD-PC3    JohnDoe JD-PC3

  3. Figure out which workspace contains the file to undo and fire up the undo command

    tf undo /workspace:JD-PC2;JohnDoe /s:http://mytfsserver:8080/tfs $/Path/To/The/File.cs

if it works, you will get the following reply:

The operation completed successfully.  Because the workspace JD-PC2;JohnDoe is not on this computer, you must perform a separate get operation in that workspace to update it with the changes that have been made on the server.

Selenium WebDriver – Element is not clickable at point

February 2, 2016 Leave a comment

Selenium is a fantastic tool for website automation, you simply nuget it into your .NET project and you will be able to use it to automate testing using Firefox

Nuget link: https://www.nuget.org/packages/Selenium.WebDriver

 

However, if you are upgrading from versions < 2.48 to the latest version, you will realize that a lot of your codes will suddenly throw the following error

OpenQA.Selenium.WebDriverException: Unexpected error. Element is not clickable at point (x, y). Other element would receive the click:

at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)

 

This is due to the way Selenium handles Mouse Clicks from version 2.48 onwards, version 2.50 is the currently “safer” version to use

https://github.com/SeleniumHQ/selenium/issues/1202

image

 

Of course all of these does not fix the issues you have with the code, here are some possible ways to fix them

#1: Use SendKeys

SendKeys automatically focuses to the element that it needs to send keys to, however this is restricted to input elements

e.g Element.SendKeys(Keys.Escape)

 

#2 Use MoveToElement

MoveToElement is another way to move focus to the element.

e.g new OpenQA.Selenium.Interactions.Actions(driver).MoveToElement(elem).Perform();

#3 Use Javascript

Javascript allows you to pretty much do anything

e.g. ((IJavaScriptExecutor)driver).ExecuteScript("window.scrollTo(" + elem.Location.X + "," + elem.Location.Y + ")")

 

#4 Use ScrollIntoView

ScrollIntoView is another  possible javascript that you can use

((IJavaScriptExecutor)driver).ExecuteScript("arguments[0].scrollIntoView(true);", element);

Quick and dirty way to generate a self signed cert that lasts 10 years

November 17, 2015 Leave a comment

While I love IIS’s and most program’s ability to generate a self signed cert, my gripe with those is that they last only a year. While a year is generally sufficient for development purposes, sometimes you want one that lasts a whole lot longer.

 

In order to get one that lasts longer, you will need to turn to openssl.

 

Here are the steps

openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650 -nodes -config ..\share\openssl.cnf

openssl pkcs12 -export -out localhost.pfx -inkey key.pem -in cert.pem

 

Parameters

– newkey: Generate a RSA 2048 bit encryption key

– keyout: the file containing the private key

– out: the file containing the certificate details

– days: how many days is this certificate valid for

– nodes: needed for pfx

– config: for windows, to specific the configuration file location

 

image

Categories: Development, General, IIS, SSL

C# Web Browser: Getting the value of a javascript property

June 28, 2012 Leave a comment

Got asked a few times how to do this, and it seems this information is somehow not easily found on the internet.

 

If you are using the .NET Web Browser control, there IS a way to get the value of a javascript property/attribute/function etc etc.

 

Assuming I have a web browser control called WB, and I want to get the cookies for the page, what I need to do is basically call eval with the parameters I want

WB.Document.InvokeScript("eval", new object[] { "document.cookie" }).ToStringX()

 

in actual code

var myCookies = WB.Document.InvokeScript("eval", new object[] { "document.cookie" }).ToStringX();
MessageBox.Show(myCookies);

 

Hope this help you guys out there Smile

Categories: Development, Visual Studio

SignalR–Configuring timeout for connections

March 2, 2012 3 comments

Based on the SignalR wiki, in order to make SignalR work with Azure or load balancers, you will need to tune it such that the polling timeout is lesser than the default polling time of 110 seconds.

To do this, the wiki at https://github.com/SignalR/SignalR/wiki/Configuring-SignalR tells you to do the following

ASP.NET Example (Global.asax)

 var config = AspNetHost.DependencyResolver.Resolve<IConfigurationManager>(); 
 config.ReconnectionTimeout = TimeSpan.FromSeconds(25);

 

However if you were to just copy and paste that, you will find that visual studio reports the following 2 errors and wurlies on your code

The name ‘AspNetHost’ does not exist in the current context

and

The type or namespace name ‘IConfigurationManager’ could not be found (are you missing a using directive or an assembly reference?)

 

image

 

Actually what happens is that the wiki actually forgot to mention that you will actually need to import a few namespaces to global.asax.

They are

  1. SignalR.Configuration – Fixes the IConfigurationManager
  2. SignalR.Hosting.AspNet – Fixes AspNetHost
  3. SignalR.Infrastructure – This is where the Resolve extension reside
      So after adding all these, your global.asax will look like

      <%@ Application Language="C#" %>

      <%@ Import Namespace="SignalR.Configuration" %>

      <%@ Import Namespace="SignalR.Hosting.AspNet" %>

      <%@ Import Namespace="SignalR.Infrastructure" %>

      <script runat="server">

          void Application_Start(object sender, EventArgs e)

          {  
              // Code that runs on application startup

              var config = AspNetHost.DependencyResolver.Resolve<IConfigurationManager>();

              config.ReconnectionTimeout = TimeSpan.FromSeconds(25);

          }

      </script>

    Enjoy!

    Categories: ASP.NET, Development Tags:

    XCode and TFS 2010 Part 1 – Setting up TFS 2010

    November 25, 2010 13 comments

    There have been many cases where i heard of users wanted to get XCode working with TFS 2010.

    Obviously out of the box, XCode does not work with TFS 2010. However there is a way to make both of them talk 🙂

    I’m outlining the steps below on how to configure both of them to communicate properly.

    For those who are lazy to download from Codeplex, you can get the required files at http://cid-895931b65435bb3d.office.live.com/self.aspx/Public/SvnBridge%20-%20Files.zip

    Step 1: Download SVNBridge from Codeplex

    The first step is to configure TFS to have a SVN bridge. To do that, head down to http://svnbridge.codeplex.com/ and download the source files (DO NOT USE THE DOWNLOAD OPTION).

    Once you downloaded all the source files, unzip them to a directory and run the build.bat

    Once the build is complete, we have are ready to deploy the SVN website.

    Step 2: Create a local user with read rights to the whole TFS

    Login to your TFS server and create a local user e.g svnbridge

    Step 3: Create folder for SVN bridge website

    Now create a folder which will store the files for the SVN bridge (e.g c:\svnbridge)

    Copy the files from SvnBridgeViaIis\bin to c:\svnbridge\bin

    Copy SvnBridgeViaIis\web.config to c:\svnbridge

    Open port 8080 on your firewall if neccessary

    Edit c:\svnbridge\web.config

    Change the TFSUrl to point to your TFS Server, e.g http://localhost:8080/tfs/DefaultCollection

    Change DomainIncludesProjectName to False

    Change LogPath to a path for the SVNBridge Logs

    Update the ReadAllUser* properties to the local user you have just created

    So now your web.config should look like

    Step 4: Setup IIS

    Run IIS Manager and Create a new website. The source directory should point to the svnbridge folder (e.g c:\svnbridge) and the port should be 8081

    Click on the authentication tab and make sure that ONLY ASP.NET impersonation and digest authentication is enabled

    Now goto Configuration editor and select the system.webServer/validation section

    Set validateIntegratedModeConfiguration to false

    Step 5: Install the Perfmon Counters

    Open the SVNBridge solution and build the SvnBridge.PerfCounter.Installer project.

    Run the SvnBridge.PerfCounter.Installer.exe found inside the bin\debug folder

    Step 6: iisreset the system

    Trigger an iisreset to flush everything and get it ready for SVN!

    Categories: Development