Skip to content

Instantly share code, notes, and snippets.

View Dillie-O's full-sized avatar

Sean Patterson Dillie-O

View GitHub Profile
@Dillie-O
Dillie-O / gist:4170626
Created November 29, 2012 17:32
Log4Net Basic TextAppender and SQLite Appender configuration
<?xml version="1.0" encoding="utf-8"?>
<log4net debug="false">
<appender name="file-appender" type="log4net.Appender.FileAppender+MinimalLock">
<file value="log-file.txt" />
<appendToFile value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
@Dillie-O
Dillie-O / gist:4172572
Created November 29, 2012 23:13
Log4Net ClientLog Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using log4net;
namespace MyApp.Web.Controllers
{
public class ClientLogController : Controller
@Dillie-O
Dillie-O / gist:4172612
Last active October 13, 2015 09:08
Log4Net ClientLog JavaScript
function LogEvent(level, message)
{
// Default to WARN level if level is not specified. Since we
// are not dependent upon the result of the logging, we leave
// the data return function empty.
level = level || "Warn";
$.ajax({
url: "/ClientLog/Log" + level + "Event",
type: "POST",
@Dillie-O
Dillie-O / gist:4494557
Created January 9, 2013 16:30
Redraw icons/labels at calculated position after SVG transform
// After applying the transform to the cities, redraw them at their new coordinates
// Select all cities with a prefix that matches the Id of the state selected.
var citySelector = "*[id^='city_" + stateId.substring(0, 2) + "']";
d3.selectAll(citySelector)
.each(function (d, i) {
var jurisdictionId = d3.select(this).attr("data-id");
d3.select("#cities")
.append("svg:circle")
@Dillie-O
Dillie-O / gist:4548290
Last active January 5, 2016 19:18
Function to calculate points on an equidistant star.
function CalculateStarPoints(centerX, centerY, arms, outerRadius, innerRadius)
{
var results = "";
var angle = Math.PI / arms;
for (var i = 0; i < 2 * arms; i++)
{
// Use outer or inner radius depending on what iteration we are in.
var r = (i & 1) == 0 ? outerRadius : innerRadius;
@Dillie-O
Dillie-O / gist:4637250
Created January 25, 2013 19:47
Remove duplicate jQuery UI dialog objects before display.
// Thank you StackOverflow!!!
// http://stackoverflow.com/questions/7099938/jquery-ui-dialog-behaves-unpredictably
var original = $('#dialogId')[0];
var clone = $(original).clone().attr('id', 'dialogIdClone');
var saveHtml = $(original).html();
$(original).html('');
$(clone).dialog({
... // other options
open: function (){
// add any dynamic behavior you need to the dialog here
@Dillie-O
Dillie-O / gist:5405986
Created April 17, 2013 17:00
Map FastCGI to PHP location for IIS Express
"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/fastCGI /+[fullPath='"C:\Program Files (x86)\PHP\php-cgi.exe"']
"C:\Program Files (x86)\IIS Express\appcmd.exe" set config /section:system.webServer/handlers /+[name='PHP_via_FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='"C:\Program Files (x86)\PHP\php-cgi.exe"',resourceType='Unspecified']
@Dillie-O
Dillie-O / gist:5549386
Created May 9, 2013 18:17
Simple SearchParameter object for EF parameterized queries. Includes constructors to account for various scenarios
public class SearchParameter
{
public string Name { get; set; }
public string Criteria { get; set; }
public string VariableName { get; set; }
public string ParameterName { get; set; }
public string ParameterType { get; set; }
public string VariableNameSecondary { get; set; }
public string ParameterNameSecondary { get; set; }
public string ParameterTypeSecondary { get; set; }
@Dillie-O
Dillie-O / gist:5549533
Last active December 17, 2015 04:19
GetSearchCriteria method that generates dictionary of SearchParameters
// All site search criteria in a dictionary for easy lookup/manipulation
// when dynamically building the query.
public static Dictionary<string, SearchParameter> GetSearchCriteria()
{
var results = new Dictionary<string, SearchParameter>
{
{
"SiteID", new SearchParameter
(
"SiteID",
@Dillie-O
Dillie-O / gist:5550329
Created May 9, 2013 20:28
Giving an existing (simple) ObjectQuery, this method dynamically adds the appropriate where clause and parameterized values based on the search criteria and parameters passed to it.
public static ObjectQuery<T> BuildObjectQuery<T>
(ObjectQuery<T> query,
NameValueCollection parameters,
Dictionary<string, SearchParameter> searchCriteria)
{
var results = query;
// If there are parameters in our collection, build a where clause
// using the search criteria dictionary. Otherwise the method ends
// and the query remains the same.