Skip to content

Instantly share code, notes, and snippets.

View HakanL's full-sized avatar

Hakan Lindestaf HakanL

View GitHub Profile
@HakanL
HakanL / StatsMixClient.cs
Created September 29, 2011 09:57 — forked from johnsheehan/StatsMixClient.cs
basic client for StatsMix REST API (updated to RestSharp 102)
using System;
using RestSharp;
namespace StatsMix
{
// Requires RestSharp
// http://restsharp.org
// http://github.com/johnsheehan/RestSharp
// Usage
@HakanL
HakanL / HighPrecisionTimer
Created January 30, 2013 00:34
C# code for a High Precision Timer (avg <1 ms for 25 ms interval). Fair use of CPU time. Uses NLog to log accuracy
using NLog;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Animatroller.Framework.Utility
{
public class HighPrecisionTimer : IDisposable
{
@HakanL
HakanL / Merger.cs
Created November 6, 2013 19:25
Class that handles merging of two lists, returning the difference as InsertList, DeleteList, MatchKeyList and ModifiedList. Also handles comparison of two different types of lists, and composite keys
using System;
using System.Collections.Generic;
using System.Linq;
namespace Haukcode
{
/// <summary>
/// Main interface for merger that requires you to set the KeySelector. Supports two different types
/// (with comparable key). Supports composite-key
/// </summary>
@HakanL
HakanL / Migration.log
Created December 17, 2013 19:29
Error log
Stopping service...
Waiting for service to stop. Current status: StopPending
Waiting for service to stop. Current status: StopPending
Waiting for service to stop. Current status: StopPending
Waiting for service to stop. Current status: StopPending
Waiting for service to stop. Current status: StopPending
Waiting for service to stop. Current status: Stopped
Service stopped
Importing Octopus 1.6 data from backup: C:\Temp\20131217-112534.octobak
Opening the destination RavenDB database...
<?xml version="1.0" encoding="utf-8" ?>
<!--
Xipton.Razor v2.5
The web.config configuration file only is for activating Razor intellisense inside Razor templates, within non MVC projects. Note
that for being able to use Razor intellisense MVC 3 or MVC 4 need to be installed on your system. MVC is not needed for compiling
Xipton.Razor templates.
You need to add the web.config to your non MVC template project besides your default app.config. The configured MVC and Razor assemblies
(here MVC version 3) need to be installed at your environment. Xipton.Razor uses Razor 2.0 (part of MVC 4), still you can use this
@HakanL
HakanL / InsufficientResources
Created March 26, 2014 00:31
Stack trace of SQL error
Unable to generate the model because of the following exception: 'System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> System.Data.SqlClient.SqlException: There is insufficient system memory in resource pool 'internal' to run this query.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
@HakanL
HakanL / pingpair_ack
Created May 5, 2015 20:24
Sample Arduino code to send a known NRF24 packet for sniffing
/*
// March 2014 - TMRh20 - Updated along with High Speed RF24 Library fork
// Parts derived from examples by J. Coliz <[email protected]>
*/
/**
* Example for efficient call-response using ack-payloads
*
* This example continues to make use of all the normal functionality of the radios including
* the auto-ack and auto-retry features, but allows ack-payloads to be written optionlly as well.
* This allows very fast call-response communication, with the responding radio never having to
if (this.currentFxChannel.FmodChannel != null)
{
this.currentFxChannel.Stop();
}
var channel = this.fmodSystem.LowLevelSystem.PlaySound(sound, this.fxGroup, true);
this.currentFxChannel = channel;
Stacktrace:
at <unknown> <0xffffffff>
at (wrapper managed-to-native) FMOD.System.FMOD_System_Update (intptr) <0xffffffff>
at FMOD.System.update () <0x00017>
at SupersonicSound.LowLevel.LowLevelSystem.Update () <0x0001f>
at Animatroller.MonoExpander.Main.Execute (System.Threading.CancellationToken) <0x00167>
at Animatroller.MonoExpander.Program.Main (string[]) <0x001cf>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <0xffffffff>
@HakanL
HakanL / WhiteBlackOut.cs
Created December 29, 2015 23:13
White out/Black out functionality
public static System.Drawing.Color AdjustColor(System.Drawing.Color input)
{
var hsv = new HSV(input);
// Test values for white out and black out
double whiteOut = 0.5;
double blackOut = 0.5;
hsv.Saturation = hsv.Saturation + (HSV.White.Saturation - hsv.Saturation) * whiteOut;
hsv.Value = Math.Min(1.0, hsv.Value + whiteOut) * (1 - blackOut);