Skip to content

Instantly share code, notes, and snippets.

View nickheppleston's full-sized avatar

Nick Heppleston nickheppleston

View GitHub Profile
@nickheppleston
nickheppleston / perfectelementary.bash
Created January 4, 2017 12:04
HowTo Install the perfect Elementary-OS
#Download Elementary OS from here:
#http://sourceforge.net/projects/elementaryos/files/stable/
#First you update your system
sudo apt-get update && sudo apt-get dist-upgrade
#Install Google Chrome
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
@nickheppleston
nickheppleston / RedisPerfTest.cs
Created November 14, 2014 11:27
Redis Performance Test - Azure Redis vs. Local Install
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using StackExchange.Redis;
namespace RedisPerfTest
{
@nickheppleston
nickheppleston / diagnostics.wadcfg
Created October 27, 2014 15:17
Azure Worker Role Diagnostics Configuration
<?xml version="1.0" encoding="utf-8"?>
<DiagnosticMonitorConfiguration configurationChangePollInterval="PT5M" overallQuotaInMB="4096" xmlns="http://schemas.microsoft.com/ServiceHosting/2010/10/DiagnosticsConfiguration">
<DiagnosticInfrastructureLogs scheduledTransferPeriod="PT5M" />
<Directories scheduledTransferPeriod="PT1M">
<CrashDumps container="wad-crash-dumps" />
<DataSources>
<DirectoryConfiguration container="wad-nlog2" directoryQuotaInMB="512">
<LocalResource relativePath="." name="CustomLogs" />
</DirectoryConfiguration>
</DataSources>
@nickheppleston
nickheppleston / MessageWorkerRole-OnStart.cs
Last active August 29, 2015 14:08
Message Worker - Worker Role - OnStart() Method
public class MessageWorker : RoleEntryPoint
{
/* This GIST only demonstrates the OnStart() method. */
public override bool OnStart()
{
Trace.WriteLine("Starting MessageWorker Worker Role Instance...");
// Initialize Worker Role Configuration
InitializeConfigurationSettings();
@nickheppleston
nickheppleston / NLogTargetManager.cs
Last active August 29, 2015 14:08
NLog SetLogTargetBaseDirectory Helper
public static class LogTargetManager
{
private static Logger logger = LogManager.GetCurrentClassLogger();
public static void SetLogTargetBaseDirectory(string targetName, string baseDirectory)
{
logger.Debug("SetLogTargetBaseDirectory() - Log Target Name: {0}.", targetName);
logger.Debug("SetLogTargetBaseDirectory() - (New) Base Directory: {0}.", baseDirectory);
var logTarget = (FileTarget)LogManager.Configuration.FindTargetByName(targetName);
@nickheppleston
nickheppleston / AzureServiceDefinition.csdef
Last active August 29, 2015 14:08
Azure Worker Role ServiceDefinition.csdef with Local Storage
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="MessageWorker" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-06.2.4">
<WorkerRole name="MessageWorker.WorkerRole" vmsize="Small">
<Imports>
<Import moduleName="Diagnostics" />
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
<ConfigurationSettings>
<Setting name="ServiceBusConnectionString" />
@nickheppleston
nickheppleston / NLogApp.config
Created October 27, 2014 11:06
NLog App.Config Showing Archive File Rotation
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="MessageWorker" xsi:type="File" fileName="logs\MessageWorker_Current.log" layout="${longdate} ${level:uppercase=true:padding=5} ${processid} ${message}" archiveFileName="logs\MessageWorker_{#}.txt" archiveEvery="Day" archiveNumbering="Date" archiveDateFormat="yyyy-MM-dd_HH-mm-ss" maxArchiveFiles="14" concurrentWrites="false" keepFileOpen="false" encoding="iso-8859-2" />
</targets>
<rules>
@nickheppleston
nickheppleston / AzureRedisCache-CacheGetSetWithSerialization.cs
Last active August 29, 2015 14:07
Azure Redis Cache - Cache StringGet/StringSet with Serialization/Deserialization to Custom .Net Type
var cacheItem = CacheSerializer.Deserialize<Guid>(cache.StringGet(cacheKey));
if (cacheItem == Guid.Empty)
{
// Cache item doesn't exist, retrieve Guid from source system.
// Add (serialized) Guid to the Azure Redis Cache with a lifespan of 90 minutes
cache.StringSet(cacheKey, CacheSerializer.Serialize(cacheItem), TimeSpan.FromMinutes(90));
}
@nickheppleston
nickheppleston / AzureRedisCache-CacheSerializer.cs
Last active August 29, 2015 14:07
Azure Redis Cache - Cache Serialization Helper
/*
* A simple generic Serialization Helper allowing custom .Net types to be stored
* in the Azure Redis Cache. Inspired by the sample at:
* http://msdn.microsoft.com/en-us/library/azure/dn690524.aspx#Objects
*/
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace AzureRedisCacheSample