Skip to content

Instantly share code, notes, and snippets.

View MarkBorcherding's full-sized avatar

Mark Borcherding MarkBorcherding

  • World Wide Technology
  • St Louis, MO
View GitHub Profile
@MarkBorcherding
MarkBorcherding / my.aspx
Created December 27, 2010 21:01
This should be all the designer needs right?
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<ProvisioningJobDetailsViewModel>" %>
Here ya go son!
// jQuery barfs because $(empty).data("autocomplete") => undefined
$(".course-autocomplete").autocomplete({
source: "/courses/autocomplete.json"
}).data("autocomplete")._renderItem = function(ul, item) {
return $("<li>")
.data("item.autocomplete", item)
.append("<a>" + item.name + "</a>")
.appendTo(ul);
};
// jQuery barfs because $(empty).data("autocomplete") => undefined
$(".course-autocomplete").autocomplete({
source: "/courses/autocomplete.json"
}).each(function(i,v){
v.data("autocomplete")._renderItem = function(ul, item) {
return $("<li>")
.data("item.autocomplete", item)
.append("<a>" + item.name + "</a>")
.appendTo(ul);
};
@MarkBorcherding
MarkBorcherding / ViewDataExtensions.cs
Created October 21, 2010 14:48
A simple set of extensions to help with casting view data.
public static class ViewDataExtensions
{
private static string Key<T>() {
return typeof (T).FullName;
}
public static T Get<T>(this ViewDataDictionary @this) {
var key = Key<T>();
return (T) (@this.ContainsKey(key) ? @this[key] : default(T));
}
[When(@"I get the URL for the route")]
public void Given_I_get_the_URL_for_the_route() {
_path = LookupOutboundUrlFrom(_routeData, usingRoutes:MyRoutes(), whileRequestingUrl:_currentPage);
}
static string LookupOutboundUrlFrom( RouteValueDictionary givenRouteValues = null,
object givenRouteData = null,
RouteCollection usingRoutes = null,
string whileRequestingUrl = "~/",
string applicationPath = "/")
<!-- you have to do this-->
<%= Html.ActionLink(job.CompanyName,"view","customer",new{id=job.CustomerId},new{}) %>
<!-- That's stupid. You have to have that empty anonymous object because in the other overload that
the route data would be the html attributes -->
<%= Html.ActionLink(job.CompanyName,"view","customer",new{ @class="link-class"}) %>
<!-- why don't we just do this -->
Scenario: Supplying invalid data for a provisioning job
Given there is a form to collect provisioning information
When I consider a form to be valid
Then the following fields are required
| field |
| admin first name |
| admin last name |
| admin email address |
| url |
| server |
var dateAsString = row["date completed"];
DateTime cd;
var completedDate = DateTime.TryParse(dateAsString, out cd) ? cd : (DateTime?)null;
<Project DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Foo Condition="$(Foo)==''">bar</Foo>
</PropertyGroup>
<Target Name="Default">
<Message Text="$(Foo)" />
</Target>
</Project>
# this is how it would be invoked as a new task in the rakefile
# you can override the hashing function or exclude/include files
revfiles :revfiles do |rev|
rev.files_to_rev << './**/*.bmp'
end