Working with JSON dates in Javascript

/Date(1224043200000)/ var date = new Date(parseInt(jsonDate.substr(6))); date.toDateString();

September 29, 2010 · 1 min · 7 words · Dan Esparza

Using HTML 5 local storage

HTML 5 includes a significant bump in what the browser itself can store (up from 4k for total cookie storage to something on the order of 5-10mb). Here’s a simple code sample that illustrates how to access local storage in HTML5: // First, make sure our browser supports HTML 5 local storage if (typeof(localStorage) == 'undefined' ) { alert('Your browser does not support HTML5 localStorage. Try upgrading.'); } else { try { // saves to the database using key/value localStorage....

September 20, 2010 · 1 min · 126 words · Dan Esparza

Using SQL tinyint columns

DataSet ds = GetDataSetFromStoredProc("stored_proc_name", new SqlParameter("@parameter_name", value_id)); var retItems = from dstable in ds.Tables[0].AsEnumerable() select new ClassThing() { PrimaryKeyId = dstable.Field<int>("some_column_name") };

September 16, 2010 · 1 min · 22 words · Dan Esparza

jQuery API browser

September 15, 2010 · 0 min · 0 words · Dan Esparza

Creating a CDN with Amazon Cloudfront

Amazon’s Cloudfront service is truly awesome. It’s a powerful, flexible, inexpensive way to get a content distribution network up and running so that you can play with the big boys on a startup budget. Getting up and running is a snap. First, make sure you’ve signed up for Amazon web services S3 and Cloudfront services. Signing up is free, but understand that Amazon charges modest fees for both S3 and Cloudfront....

September 13, 2010 · 2 min · 290 words · Dan Esparza

Using the jQuery UI 'transfer' effect

When using the jQuery UI ’transfer’ effect for the first time, you might think the effect isn’t working. The documentation is sparse, but the call looks simple enough: // Use transfer effect $("#txtProduct").effect("transfer", { to: $("#test") }, 1000); If you add this to your page, add the html elements to make this work, and then run this code you’ll notice … absolutely nothing. That’s because you need to style the actual ’transfer effect’ itself....

September 12, 2010 · 1 min · 99 words · Dan Esparza

How to delete data from multiple tables at once in SQL

The short answer is you can’t. But there is a very nice workaround. I was perusing StackOverflow and came across this article talking about how to capture information from deleted rows and then use them in a join using the deleted pseudo table: How do I delete from multiple tables using INNER JOIN in SQL server - Stack Overflow begin transaction; declare @deletedIds table ( id int ); delete t1 /* Notice this next line is using the 'deleted' pseudo table: */ output deleted....

September 10, 2010 · 1 min · 123 words · Dan Esparza

Performing a join using LINQ

So what do you do when you’re using the nifty new ’entity framework’ and you’re getting data back with LINQ queries and you’ve reached the point where you want to get data back based on criteria in a related table? Well, if you’re not using a stored proc to do it for you – you’ve got to do a join. The join syntax in LINQ is similar to SQL syntax, but not quite the same....

September 6, 2010 · 1 min · 121 words · Dan Esparza

ASP.NET MVC2 custom validation helper

RedGate reflector and ASP.NET MVC2 rock. Using this extension method: /// <summary> /// If the given model field has validation errors, this will emit the given CSS class name /// </summary> /// <typeparam name="TModel"></typeparam> /// <typeparam name="TProperty"></typeparam> /// <param name="htmlHelper"></param> /// <param name="expression"></param> /// <param name="cssClassToEmit"></param> /// <returns></returns> public static MvcHtmlString ValidationCSSClassFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, string cssClassToEmit) { MvcHtmlString htmlString = null; // Figure out the expression text from the LambdaExpression using our nifty helper // (thank God for RedGate reflector or I would have never figured this one out) string expressionText = ExpressionHelper....

July 13, 2010 · 2 min · 233 words · Dan Esparza