Skip to content

Instantly share code, notes, and snippets.

@benhysell
benhysell / merge numbering
Created October 30, 2014 14:11
Merge Numbering DocX
private void merge_numbering(PackagePart remote_pp, PackagePart local_pp, XDocument remote_mainDoc, DocX remote)
{
// Add each remote numbering to this document.
IEnumerable<XElement> remote_abstractNums = remote.numbering.Root.Elements(XName.Get("abstractNum", DocX.w.NamespaceName));
//get next abstract number from base document
var documentAbstractNumbers = numbering.Root.Elements(XName.Get("abstractNum", DocX.w.NamespaceName));
int guidd = 0;
foreach (var an in documentAbstractNumbers)
@benhysell
benhysell / ILMerge.exe.config
Created November 5, 2014 14:25
Visual Studio ilmerge
<!--Also create ILMerge.exe.config where ILMerge is installed, C:\Program Files (x86)\Microsoft\ILMerge -->
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
</startup>
</configuration>
@benhysell
benhysell / DatabaseCall.cs
Last active May 14, 2024 02:59
c# Redis Caching Objects with StackExchange.Redis using Json
//extension method make a database call by providing a function pointer to Task<T> and passing in a method parameter
public static async Task<T> DatabaseCall<T>(this IDatabase cache, string key, Func<string, Task<T>> databaseCall, string methodParameter, TimeSpan timeSpan, bool invalidate, bool useCache)
{
T returnValue;
var cachedItem = default(T);
try
{
cachedItem = await cache.GetAsync<T>(key);
}
catch (RedisConnectionException ex)
@benhysell
benhysell / VerticalGraphView.cs
Created January 14, 2015 14:14
OxyPlot MvvmCross Binding
// --------------------------------------------------------------------------------------------------------------------
// <summary>
// Defines the VerticalGraphView type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
using System.Drawing;
using Cirrious.CrossCore;
using Cirrious.FluentLayouts.Touch;
using Cirrious.MvvmCross.Binding.BindingContext;
@benhysell
benhysell / FileDownload.cshtml
Created January 21, 2015 16:28
Kendo UI Grid Paging and Sorting c# asp.net webapi
<div id="fileDownloadGrid"></div>
<br />
@section Scripts {
$("#fileDownloadGrid").kendoGrid({
dataSource: new kendo.data.DataSource({
transport: {
read: {
url: "../../../api/Vehicles/VehicleFilesApi",
data: additionalFileData(),
cached: false,
@benhysell
benhysell / gist:8d50a9a7cc0b06b4c112
Created January 24, 2015 19:19
Configure Enterprise Library 6.0 Logging
IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
Logger.SetLogWriter(logWriterFactory.Create());
@benhysell
benhysell / web.config
Created January 24, 2015 19:21
Hangfire web.config category settings for Enterprise Logging 6.0
<categorySources>
<add switchValue="Warning" name="Hangfire.BackgroundJobServer">
<listeners>
<add name="Email - Fail" />
</listeners>
</add>
<add switchValue="Warning" name="Hangfire.Server.AutomaticRetryServerComponentWrapper">
<listeners>
<add name="Email - Fail" />
</listeners>
@benhysell
benhysell / gist:10c1eb546bd3401ee50f
Created January 28, 2015 03:08
c# HttpClient Ignore Certificate - for local certificates
using (var client = new HttpClient())
{
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
var response = await client.GetAsync(reqUrl);
response.EnsureSuccessStatusCode();
if (!Convert.ToBoolean(await response.Content.ReadAsStringAsync()))
throw new Exception("Response from webserver was false.");
}
@benhysell
benhysell / gist:accf6a23fde8dbe7ddfe
Created January 28, 2015 16:04
Kendo UI Grid Passing Dates To asp.net
http://blog.falafel.com/passing-dates-kendo-ui-aspnet/
var _dateToString = function (date) {
return kendo.toString(kendo.parseDate(date), "G");
};
@benhysell
benhysell / ApplicationName.nuspec
Created March 10, 2015 19:32
NuSpec National Instruments Measurement Studio with Squirrel Distribution
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>ApplicationNameNoSpaces</id>
<version>$version$</version>
<authors>benh</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Application Name</description>
</metadata>
<files>