Skip to content

Instantly share code, notes, and snippets.

View mlehmk's full-sized avatar

Marc Lehmkühler mlehmk

View GitHub Profile
using System;
using System.Collections;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
namespace HaSeWaWiModule
{
/* minimalistic AMD implementation (experimental)
* put following script as first before all other script tags in the header
<script>
function define(){define.$.push(arguments)}define.$=[];define.amd={};
</script>
* then load all other scripts in any order with async
*/
//define=define||(function(){var define=function(){define.$.push(arguments);};define.$=[];define.amd={};return define;})();
(function(global){
"use strict";

Keybase proof

I hereby claim:

  • I am mlehmk on github.
  • I am mlehmk (https://keybase.io/mlehmk) on keybase.
  • I have a public key ASC7yOFmN2BAKOqmhGis2OhPIjfXW9lX1lmhBuUmNgsxgQo

To claim this, I am signing this object:

using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace CustomNamespace
{
public class Guard
{
private SemaphoreSlim _semaphore = new SemaphoreSlim(1);
@mlehmk
mlehmk / RangeCoder.cs
Created December 2, 2015 14:25
Compression
using System;
using System.IO;
using System.Linq;
using System.Security.Permissions;
using System.Text;
namespace Compression
{
public class RangeCoder : IDisposable
{
using System;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
public class HashingStream : CryptoStream
{
private readonly SHA256 _hasher;
private string _hash = null;
private byte[] _hashBytes = null;
@mlehmk
mlehmk / gist:38ecdfa5af5a596efb81
Created June 1, 2015 10:05
CopyToOutput.targets
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UseCommonOutputDirectory>true</UseCommonOutputDirectory>
</PropertyGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="@(ReferenceCopyLocalPaths)" DestinationFiles="@(ReferenceCopyLocalPaths->'$(SolutionDir)$(Configuration)\lib\%(DestinationSubDirectory)%(Filename)%(Extension)')" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll' Or '%(ReferenceCopyLocalPaths.Extension)' == '.pdb'"/>
</Target>
<Target Name="AfterClean">
<RemoveDir Directories="$(SolutionDir)$(Configuration)\lib"/>
</Target>
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
private static char HexDigit(int p)
{
if (p < 10) return (char)(48 + p);
return (char)(87 + p);
}
public static string ToHexString(this byte[] ba)
{
char[] digits = new char[ba.Length * 2];
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace NotifyImpl
@mlehmk
mlehmk / CsExpression.g3
Created June 12, 2014 10:57
ExpressionMaker
grammar CsExpression;
options {
language=CSharp3;
TokenLabelType=CommonToken;
output=AST;
ASTLabelType=CommonTree;
}
@lexer::namespace{ExpressionParser}