I spent a few days playing with Ruby on Rails a while back. During the learning experience, there was one particular feature that I really liked. It was the database migration scripts that get automatically generated for you. I always wished I had something like this in the windows (asp.net) world. It turns out there […]
Entries Categorized as 'Tips & Tricks'
Database Schema Compare & Upgrade
July 10, 2008
Unit Test Private Methods in Visual Studio
July 9, 2008
I am working on a feature that will let me import twitter messages to yonkly and wanted to write a test for it. The method is private and I couldn’t get the unit test to see it. I also didn’t want to use the private accessor class generate by Visual Studio because I was mocking […]
Shortening URLs Using TinyUrl API in .net
April 15, 2008
Here is a quick method to shorten URLs using the TinyUrl API in .net - C# and VB
C#
public static string MakeTinyUrl(string Url)
{
try
{
if (Url.Length <= 30)
{
return Url;
}
if (!Url.ToLower().StartsWith(“http”) && !Url.ToLower().StartsWith(“ftp”))
{
Url = “http://” + Url;
}
var request = WebRequest.Create(“http://tinyurl.com/api-create.php?url=” + Url);
var res = request.GetResponse();
string text;
using (var reader = new StreamReader(res.GetResponseStream()))
{
text = reader.ReadToEnd();
}
return text;
}
catch (Exception)
{
return Url;
}
}
VB
Public Shared Function MakeTinyUrl(ByVal […]
Tricky Asp.net MVC URL Rewriting
April 10, 2008
I am working on an asp.net mvc application and I wanted to make the user’s main page (profile) be www.domain.com/username. This is a problem because the routing engine in MVC treats the first item after the domain as a controller. Ofcourse I could do a {*catchall} and do my own parsing but why re-invent the […]
My Elevator Pitch
March 30, 2008
I found this cool site that has a free wizard which helps you build your elevator (15 second) pitch. Here are some of my pitches:
Consultant
My name is Emad Ibrahim and I am a consultant specializing in .net development. I architect, design and create software. I can do it faster and better than the competition. […]
Cross Domain Error Fix for Silverlight
March 18, 2008
The easiest/quickest way to fix a cross domain error is to create a test website to host your Silverlight application.
When you hit F5 to debug the application, it will run the development server and the address bar will say http://localhost:xxx/blahblah. This will prevent a cross-domain error.
If you try to run it using an test html […]
Set a Clip in Code-Behind
March 17, 2008
You can use the Clip property on any item to clip its display area. For example if you have this two items rectBlue and rectRed like this
And you want to animate rectRed by sliding it out from the right side, without clipping it would look like this
But if you set the Clip property on […]
Silverlight Tip: Stretch Canvas to Fill the Screen
March 13, 2008
I am not sure if this is a bug or by-design but Canvases don’t stretch the way I expect them to - the Grid control seems to resize better.
If you want your Canvas to stretch and Fill its parent, there is an easy way to do this.
1. On initialization, set the Canvas width and height […]
Silverlight Tip: Fill the browser window
March 12, 2008
RE: Silverlight 2 Beta 1 with Blend 2.5 March 2008 Preview
You can Make your XAML silverlight page fit the whole browser window.
In Blend, select the user control from the objects and timeline
Set the width and height to Auto and the horizontal and vertical alignment to stretch
There will be arrows surrounding the control that lets you […]
Get Enum Value from String
February 20, 2008
Here is a quick tip. If you have the following Enum
Enum Frequencies
DAILY
WEEKLY
MONTHLY
End Enum
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, “Courier New”, courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { […]
Posted in
content rss
