Tips & tricks

Using Google App Engine as Proxy for Silverlight and Flash Cross-Domain Requests

When using Silverlight or Flash to fetch data from other domains one often runs into cross-domain access restrictions. For security reasons in order to access data from different domains, the remote server explicitly has to allow this by defining a crossdomain.xml (or, for Silverlight, clientaccesspolicy.xml is good as well). If this file cannot be found on the remote domain, the request is not executed.

This can be fustrating when querying against RSS feeds or JSON/XML web APIs that don’t define any of these files. The workaround for this issue is to use some sort of proxying service. In this article I’ll be showing how to use Google App Engine to create a simple proxy that will forward these requests for free – within a reasonable daily load.

Google App Engine Overview

The reason I’ve chose to implement the proxy using Google App Engine is because it has a free daily quota and getting started using it is really simple: all you need is a Google account and to download and install the Google App Engine SDK.

Google App Engine supports developing in both Java and Python. In my example I’ll be using Python. In order to use and deploy the code yourself as well, follow these steps:
Read More…

Setting the StrokeDashArray using a Style in Silverlight

I’ve recently ran into an issue: I wanted to draw an element with a dashed stroke using a Style I’ve created on the fly. To my surprise I couldn’t.

The Problem

The type of the StrokeDashArray (that is defined on Shape) is a DoubleCollection. So naturally I tried setting a DoubleCollection instance as the Value of the Setter on the Style I created:

Style ellipse2Style = new Style(typeof(Ellipse));
// Setting a DoubleCollection as the Value of the Setter for StrokeDashArrayProperty doesn't work!
ellipse2Style.Setters.Add(new Setter(Ellipse.StrokeDashArrayProperty,new DoubleCollection() { 2, 2 }));
Ellipse2.Style = ellipse2Style;

Read More…

Ten Cool Visual Studio 2010 Features

I’ve attended an event late March in Glasgow where Scott Guthrie, Microsoft vice president showed off some of the new fewatures of Visual Studio 2010. Based on this talk and my experience using Visual Studio 2010 Beta 2 and the Release Candidate I’ve collected the ten most useful new features of this edition. These are:

  • Pinning variables when debugging
  • Box selection
  • On-the-fly search
  • Zooming
  • View call hierarchy
  • Sequence diagrams
  • Dependency graphs
  • IntelliTrace and dump debugging
  • Multi-monitor support
  • Intellisense improvements

For a detailed description of each of these features read my blog post Ten Cool Things You Didn’t Know About Visual Studio at my Scott Logic blog.

Querying many-to-many relations in NHibernate

I’ve ran into a querying scenario with NHibernate that was much less obvious to solve with the NHibernate query API than it would have been with SQL – for me at least.

In my model I’ve had a simple many-to-many relation: Entries that had multiple Categories each and Categories that belonged to multiple Entries as well.

Categories and Entries: an Entity-Relationship Diagram

Categories and Entries: a many-to-many relationship

In the underlying SQL model the many-to-many relationship was implemented via a relationship table:

Many-to-many relationship table structure

Categories and Entries table structure

Now I wanted to find all entites within a given category. Pretty simple, right? In SQL it would have been a simple join:

SELECT Entry.* FROM Entry JOIN Category_rel_Entry ON Category_rel_Entry.Entry_ID = Entry.ID WHERE Category_rel_Entry.Category_ID = @CategoryId

In Nhibernate this query is a bit more tricky, let me share how it can be done.

Note: this post is also a good example of how to define a many to many relationship schema in NHibernate.

Read More…

How to resample images – a simple algorithm

When working with images I sooner or later usually run into the problem of creating thumbnails. Resampling images is not really difficult in the major programming languages however I have not found built-in support for caclulating thumbnail dimensions neither in .NET nor in PHP. And it seems that this made me re-invent the wheel over and over again creating codes with various lengths just for this simple task.

In Sense/Net 6.0, the open source ECMS I am working on I came across the exact same problem: I wanted to resize images, this time on the fly. This time however I decided to do it a bit less complicated as in previous cases and create a clean and simple solution. After a good deal of googling, tutorial reading and planning I came up with a fairly simple and good code snipplet.

Read More…

ASP.NET server side element names changed?

As far as I’ve known if the ClientID of a server control looked someting like this:


Then the name sent on postback (which identified the control on the server side) was:


But since some time the _ to $ conversion is not true any more. Instead the _ signs are randomly replaced by dollar signs. Recently the name sent back on postback is:


This change screwed up quite a lot of client side manual __doPostback() codes I’ve written – most of the making these invokes due to JQuery addons.
Read More…

Deleting a one-to-many relationship in NHibernate

I have had some trouble deleting the child in a one-to-many relationship in NHibernate. My schema described a simple parent-child relationship: a parent can have multiple children and every child has exactly one parent.

In the database schema I had two tables parentTable and childTable. ParentTable had an ID column and some other columns. The childTable had an ID primary key column, some other columns and a parentId NOT NULL column which had a foreign key constraint against the ID column in the parentTable.

Parent-Child Database Relationship (One-to-many)

Read More…

TFS – deleting old workspaces

I use Visual Studio 2008 on a daily basis however for some older projects I have to work with VS 2005. Recently our company has set a new Team Foundation Server in use and all active projects have been migrated there. In VS 2008 everything worked just fine.

However when trying to re-map a project to the same localtion as before (only from the new TFS server) I got the following error message: “The path [yourpath] is already mapped in workspace [yourworkspace]“. It took me a while to figure out what the resolution of the problem was.
Read More…

 Scroll to top