This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web.Mvc; | |
using System.Web.Routing; | |
namespace jarrettmeyer.Web.Lib | |
{ | |
public static class RouteHelpers | |
{ | |
/// <summary> | |
/// Connects a distinct path to a controller/action. | |
/// </summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Get all HTTP POSTed Files that were uploaded as part of a | |
/// multipart form POST. This abstraction keeps the controller | |
/// from dealing with the Request object directly. | |
/// </summary> | |
public IEnumerable<HttpPostedFileBase> HttpPostedFiles | |
{ | |
get | |
{ | |
// _httpContext has been pre-assigned to be the current HttpContextBase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// jQuery UI combobox | |
// Based on the combobox example on the jQuery UI home page. | |
// Must load both jQuery and jQuery UI Widgets before loading this document. | |
// I use CSS to position the button inside the input element, so it looks just | |
// like a drop down box. | |
// | |
$.widget("ui.combobox", { | |
_create: function () { | |
var self = this; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Because I am an idiot and keep on using 'append', instead of 'push'. | |
Array.prototype.append = function (item) { | |
this.push(item); | |
return this; | |
}; | |
// Returns true if the given item is contained in the array. | |
Array.prototype.contains = function (item) { | |
for (var i = 0; i < this.length; i++) { | |
if (this[i] == item) return true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$.fn.deleteLink = function (options) { | |
var defaults = { | |
event: "click", // Type of event to bind. This will almost always be a "click" event. | |
url: undefined, // If the URL is undefined, then we will find the URL on the element. | |
attr: "href", // Attribute that contains the URL. If a link, then this is probably an "href" attribute. | |
data: "", // Data sent with the AJAX request. | |
dataType: "html", // Type of data returned on the AJAX request. | |
type: "DELETE", // Type of request to send. Probably should be either a "DELETE" or "POST". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function ($) { | |
$.fn.buildSelectList = function (options) { | |
defaults = { | |
url: null, // URL for the select list options. | |
data: null, // Data to be passed to the URL. | |
value: null, // Currently selected option value. | |
valueProperty: "value", // JSON property for option value. | |
textProperty: "text", // JSON property for option text. | |
type: "GET", // JSON HTTP method. | |
useCache: false, // Allow outputs to be cached. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ObjectToDictionaryHelper | |
{ | |
public static IDictionary<string, object> ToDictionary(this object source) | |
{ | |
return source.ToDictionary<object>(); | |
} | |
public static IDictionary<string, T> ToDictionary<T>(this object source) | |
{ | |
if (source == null) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Pluralization | |
{ | |
private static readonly ConcurrentDictionary<string, string> dictionary; | |
private static Func<string, string> defaultPluralizationRule = (s) => s.EndsWith("s") ? "es" : "s"; | |
static Pluralization() | |
{ | |
dictionary = new ConcurrentDictionary<string, string>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EmailValidator | |
{ | |
private const string PATTERN = "^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$"; | |
public static bool IsValid(string s) | |
{ | |
if (string.IsNullOrEmpty(s)) | |
return false; | |
// Regex from http://www.regular-expressions.info/email.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GEM | |
remote: http://rubygems.org/ | |
specs: | |
RedCloth (4.2.9) | |
albino (1.3.3) | |
posix-spawn (>= 0.3.6) | |
blankslate (2.1.2.4) | |
chunky_png (1.2.5) | |
classifier (1.3.3) | |
fast-stemmer (>= 1.0.0) |
OlderNewer