Skip to content

Instantly share code, notes, and snippets.

@aGiftKit
aGiftKit / Create Dto
Created August 3, 2014 13:58
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 August 29, 2015 14:01
We use this function to encode the data that we are preparing to send in an Ajax call.
// 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 August 29, 2015 14:01
A class to return Metadata from a running Amazon instance. (aws, webclient, timeout, availabiltyzone)
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 August 29, 2015 14:01
Used to replace all occurrences of a string within another string.
function ReplaceAll(string, search, replacement) {
// http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript
return string.split(search).join(replacement);
}