Skip to content

Instantly share code, notes, and snippets.

View jgeurts's full-sized avatar

Jim Geurts jgeurts

View GitHub Profile
@jgeurts
jgeurts / statsd-graphite-install.sh
Last active January 28, 2017 20:23
Install statsd and graphite as a services on Ubuntu 13.10
sudo apt-get install --assume-yes python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install --assume-yes nodejs
sudo apt-get install --assume-yes git
# Install Graphite
sudo apt-get install python-dev ruby-dev bundler build-essential libpcre3-dev graphite-carbon graphite-web
cat >> /tmp/graphite-carbon << EOF
# Change to true, to enable carbon-cache on boot
@jgeurts
jgeurts / gist:5847108
Created June 24, 2013 00:49
Install nginx on Ubuntu 13.04
# 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
@jgeurts
jgeurts / gist:3372865
Created August 16, 2012 19:22
Missing statsd dashboard additions to Graphite
# 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])
@jgeurts
jgeurts / AndroidAutoIncrementVersion.cs
Created July 17, 2012 20:03
Update android version strings
using System.IO;
using System.Text.RegularExpressions;
namespace AndroidAutoIncrementVersion
{
class Program
{
static void Main(string[] args)
{
try
@jgeurts
jgeurts / install-graphite-ubuntu-12.04.sh
Created July 14, 2012 16:36 — forked from tkoeppen/install-graphite-ubuntu-10.04.sh
Install Graphite 0.9.10 on Ubuntu 12.04
####################################
# BASIC REQUIREMENTS
# http://graphite.wikidot.com/installation
# http://geek.michaelgrace.org/2011/09/how-to-install-graphite-on-ubuntu/
# Last tested & updated 10/13/2011
####################################
cd
sudo apt-get update
sudo apt-get upgrade
@jgeurts
jgeurts / gist:2992417
Last active October 6, 2015 12:18
Configure StructureMap dependency resolver
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
@jgeurts
jgeurts / StructureMapDependencyResolver.cs
Last active January 25, 2016 22:38
StructureMap MVC 4 dependency resolver adapter
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>
@jgeurts
jgeurts / gist:1855768
Created February 17, 2012 22:20
Get a list of most visited pages
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;
@jgeurts
jgeurts / gist:1855745
Created February 17, 2012 22:15
Get general analytics stats stats
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)
@jgeurts
jgeurts / gist:1855718
Created February 17, 2012 22:08
Query the Google Analytics account feed to get a list of available sites
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))