Skip to content

Instantly share code, notes, and snippets.

View Create Dto
public class TestPerson : DtoBase, IValidatableObject
{
public string Title { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Initials { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
//if (Id == 0)
@aGiftKit
aGiftKit / UrlEncodeObj
Last active Aug 29, 2015
We use this function to encode the data that we are preparing to send in an Ajax call.
View UrlEncodeObj
// return object as URL encoded string
// I did not write this code, it was pasted from somewhere.
UrlEncodeObj = function (o) {
var sdata = '';
for (var k in o) {
if (sdata) {
sdata += '&';
}
sdata += k + '=' + escape(o[k]);
}
@aGiftKit
aGiftKit / Aws Metadata Helper
Last active Aug 29, 2015
A class to return Metadata from a running Amazon instance. (aws, webclient, timeout, availabiltyzone)
View Aws Metadata Helper
public class AwsHelper
{
private const string LOG_PREFIX = "AwsHelper/";
/* A class to return Metadata from a running Amazon instance.
Requires: using System.Net;
We call these methods in the startup routine of our windows service.
@aGiftKit
aGiftKit / ReplaceAll
Last active Aug 29, 2015
Used to replace all occurrences of a string within another string.
View ReplaceAll
function ReplaceAll(string, search, replacement) {
// http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript
return string.split(search).join(replacement);
}