Skip to content

Instantly share code, notes, and snippets.

View jgeurts's full-sized avatar

Jim Geurts jgeurts

View GitHub Profile
@jgeurts
jgeurts / gist:1855675
Created February 17, 2012 21:52
AuthSub authentication for Google api
public ActionResult Auth()
{
const string scope = "https://www.google.com/analytics/feeds/";
var next = Url.FullPath("~/home/authresponse");
var url = AuthSubUtil.getRequestUrl(next, scope, false, true);
return Redirect(url);
}
public ActionResult AuthResponse(string token)
{
@jgeurts
jgeurts / EnumerableExtensions.cs
Created January 17, 2012 14:26
Select list enumerable extensions
public static class EnumerableExtensions
{
public static IEnumerable<SelectListItem> ToSelectListItems<T>(this IEnumerable<T> items, Func<T, string> name, Func<T, string> value, string selectedValue)
{
return items.ToSelectListItems(name, value, selectedValue, false);
}
public static IEnumerable<SelectListItem> ToSelectListItems<T>(this IEnumerable<T> items, Func<T, string> name, Func<T, string> value, string selectedValue, bool includeNotApplicable, string notApplicableValue = "", string notApplicableText = "(Not Applicable)")
{
return items.ToSelectListItems(name, value, x => value(x) == selectedValue, includeNotApplicable, notApplicableValue, notApplicableText);