Skip to content

Instantly share code, notes, and snippets.

@ejsmith
ejsmith / each_with_index.js
Created Dec 11, 2012 — forked from dsci/each_with_index.js
each_with_index handlebars helper, adds an {{index}} prop accessible from within the block
View each_with_index.js
// {{#each_with_index records}}
// <li class="legend_item{{index}}"><span></span>{{Name}}</li>
// {{/each_with_index}}
Handlebars.registerHelper("each_with_index", function(array, fn) {
var buffer = "";
for (var i = 0, j = array.length; i < j; i++) {
var item = array[i];
// stick an index property onto the item, starting with 1, may make configurable later
@ejsmith
ejsmith / each_with_index.coffee
Created Dec 11, 2012 — forked from burin/each_with_index.coffee
each_with_index handlebars helper, adds an {{index}} prop accessible from within the block
View each_with_index.coffee
Handlebars.registerHelper 'each_with_index', (array, fn) ->
buffer = ''
for i in array
item = i
item.index = _i
buffer += fn(item)
buffer
@ejsmith
ejsmith / gist:6081109
Created Jul 25, 2013
Exceptionless config file samples
View gist:6081109
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="exceptionless" type="Exceptionless.Configuration.ExceptionlessSection, Exceptionless" />
</configSections>
<!-- attribute names are cases sensitive, must specify a path that you have write access to -->
<exceptionless apiKey="API_KEY_HERE" enableLogging="true" logPath="C:\log.txt" />
...
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
@ejsmith
ejsmith / gist:6082335
Last active Dec 20, 2015
Sample console app for Exceptionless
View gist:6082335
using System;
using CodeSmith.Core.Helpers;
using Exceptionless;
namespace SampleConsole {
internal class Program {
private static void Main() {
ExceptionlessClient.Current.Startup();
SendOne();
ExceptionlessClient.Current.ProcessQueue();
View Bootstrap.cs
Bootstrap.Run(config => {
config.IncludeAssemblyFor<Type>();
config.IncludeAssembly(Assembly);
config.UseAutoMapper(mapper => mapper.UseSomeOption());
config.UseAutofac();
config.LogToConsole();
};
Bootstrap.Run(config =>
config
View project.json
{
"version": "0.1-alpha-*",
"compilationOptions": {
"warningsAsErrors": true
},
"dependencies": {
"Microsoft.AspNet.Http": "0.1-alpha-*",
"Microsoft.AspNet.Mvc.Common": "",
"Microsoft.AspNet.Mvc.ModelBinding": "",
"Microsoft.AspNet.Routing": "0.1-alpha-*",
@ejsmith
ejsmith / Program.cs
Last active Aug 29, 2015
Examples of using the Exceptionless 2.0 client
View Program.cs
var client = new ExceptionlessClient(config => {
// Set your API key.
config.ApiKey = "API_KEY_HERE";
// Send events to your own free Exceptionless server install.
config.ServerUrl = "https://exceptionless.myorg.com";
// Read config settings from attributes.
config.ReadFromAttributes();
@ejsmith
ejsmith / EmptyCollectionContractResolver.cs
Created Aug 6, 2014
EmptyCollectionContractResolver
View EmptyCollectionContractResolver.cs
class EmptyCollectionContractResolver : DefaultContractResolver {
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) {
JsonProperty property = base.CreateProperty(member, memberSerialization);
Predicate<object> shouldSerialize = property.ShouldSerialize;
property.ShouldSerialize = obj => (shouldSerialize == null || shouldSerialize(obj)) && !IsEmptyCollection(property, obj);
return property;
}
private bool IsEmptyCollection(JsonProperty property, object target) {
View Exceptionless.json
{
"title": "Exceptionless",
"services": {
"query": {
"list": {
"0": {
"id": 0,
"color": "#7EB26D",
"alias": "",
"pin": false,
View gist:1b5f03f676fcd539f6cd
-------------------------------------
Session Tracking
-------------------------------------
Exceptionless can also track user sessions which enables powerful application analytics.
Session tracking can be enabled by simply adding this line to the startup of your application:
ExceptionlessClient.Default.Configuration.UseSessions()