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 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); |
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
var authFactory = new GAuthSubRequestFactory("analytics", ApplicationName) | |
{ | |
Token = settings.SessionToken | |
}; | |
var analytics = new AnalyticsService(authFactory.ApplicationName) { RequestFactory = authFactory }; | |
foreach (AccountEntry entry in analytics.Query(new AccountQuery()).Entries) | |
{ | |
var account = entry.Properties.First(x => x.Name == "ga:accountName").Value; | |
if (!model.Sites.ContainsKey(account)) |
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
var topPages = new DataQuery(settings.SiteId, from, to) | |
{ | |
Metrics = "ga:pageviews", | |
Dimensions = "ga:pagePath,ga:pageTitle", | |
Sort = "-ga:pageviews", | |
NumberToRetrieve = 20 | |
}; | |
foreach (DataEntry entry in analytics.Query(topPages).Entries) | |
{ | |
var value = entry.Metrics.First().IntegerValue; |
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
var siteUsage = new DataQuery(settings.SiteId, from, to) | |
{ | |
Metrics = "ga:visits,ga:pageviews,ga:percentNewVisits,ga:avgTimeOnSite,ga:entranceBounceRate,ga:exitRate,ga:pageviewsPerVisit,ga:avgPageLoadTime" | |
}; | |
var siteUsageResult = (DataEntry)analytics.Query(siteUsage).Entries.FirstOrDefault(); | |
if (siteUsageResult != null) | |
{ | |
foreach (var metric in siteUsageResult.Metrics) | |
{ | |
switch (metric.Name) |
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 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) | |
{ |
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 MvcKickstart.Infrastructure; | |
using StructureMap; | |
[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(YourProject.IocConfig), "PreStart", Order = -100)] | |
// This gets installed automatically with the MvcKickstart nuget (https://nuget.org/packages/mvckickstart) | |
namespace YourProject | |
{ | |
public static class IocConfig |
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.IO; | |
using System.Text.RegularExpressions; | |
namespace AndroidAutoIncrementVersion | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try |
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
# Add to /opt/graphite/webapp/graphite/render/functions.py (Around the "def movingAverage(" line): | |
def historicalAverage(requestContext, seriesLists, points=7, offset=86400, highPassCount=1, lowPassCount=1): | |
historicalLists = [] | |
for series in seriesLists: | |
hlist = [] | |
for i in range(1,points+1): | |
tShift = str(offset * i) + "s" | |
shiftedSeries = timeShift(requestContext, [series], tShift) | |
hlist.append(shiftedSeries[0]) |
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; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Microsoft.Practices.ServiceLocation; | |
using StructureMap; | |
// This is part of MvcKickstart (https://nuget.org/packages/mvckickstart) | |
namespace MvcKickstart.Infrastructure | |
{ | |
/// <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
# From: http://www.cyberciti.biz/tips/using-nginx-as-reverse-proxy.html | |
# and: http://www.cyberciti.biz/faq/howto-linux-unix-setup-nginx-ssl-proxy/ | |
# and: http://nginx.org/en/docs/http/websocket.html | |
# Run the following commands as su | |
sudo -s | |
# Use the stable version of nginx | |
nginx=stable | |
# Add nginx repository source | |
add-apt-repository ppa:nginx/$nginx |
OlderNewer