Skip to content

Instantly share code, notes, and snippets.

Avatar

Vladimir Kozlov aienabled

View GitHub Profile
View DeviceStateHelperD3D11.cs
namespace NoesisGUI.MonoGameWrapper.Helpers.DeviceState
{
using System;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using SharpDX.Mathematics.Interop;
using Buffer = SharpDX.Direct3D11.Buffer;
using Device = SharpDX.Direct3D11.Device;
View LerpWithDeltaTime.cs
// see https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
public static double LerpWithDeltaTime(double a, double b, double deltaTime, double rate)
{
return Lerp(b, a, Math.Pow(2, -rate * deltaTime));
}
// see https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
public static float LerpWithDeltaTime(float a, float b, float deltaTime, float rate)
{
return Lerp(b, a, Math.Pow(2, -rate * deltaTime));
@aienabled
aienabled / Convert-ToPackageReference.ps1
Last active Oct 12, 2017 — forked from a4099181/Convert-ToPackageReference.ps1
Converts packages.config into PackageReference at *.csproj project file. Requires XSLT stylesheet available as second file in the gist.
View Convert-ToPackageReference.ps1
Function Convert-ToPackageReference
{
Param ( [Parameter( Mandatory, ValueFromPipeline )][String] $inputUri,
[String] $stylesheetUri = "https://gist.githubusercontent.com/a4099181/074a6c3dd524ea0d343382137492399c/raw/e2cd1bc88671bb1435569ba9ab1835994aa91725/Convert-ToPackageReference.xsl",
[String] $resultsFile = [System.IO.Path]::GetTempFileName() )
Process {
$xslt = New-Object System.Xml.Xsl.XslCompiledTransform
$xslt.Load( $stylesheetUri )
$xslt.Transform( $inputUri, $resultsFile )
@aienabled
aienabled / C# 7.0 ReSharper improvements.md
Last active Mar 8, 2017
C# 7.0 pattern matching rewriter for ReSharper (search and replace with pattern, automatic replace)
View C# 7.0 ReSharper improvements.md

C# 7.0 brings many syntax improvements and features. One of the most valuable is the new pattern matching syntax. Usually it's used with switch blocks but it has another great use with if conditions. Currently there are no auto-replacement or auto-suggestion for that case in ReSharper yet (at current version 2017.1 EAP 2), but we could easily add it. But first let's consider the problem and improvements C# 7.0 brings us.

Pattern matching at if statement with is operator

For example, consider this code:

if (obj is FooType)
{
    var fooObj = (FooType)obj;
@aienabled
aienabled / RoslynWpfToNoesisPreprocessor.cs
Created Feb 16, 2017
Preprocessor to make C# code for WPF compatible with NoesisGUI (replace System.Windows namespaces)
View RoslynWpfToNoesisPreprocessor.cs
public static SyntaxNode ProcessSyntaxTree(
SyntaxTree syntaxTree,
ConcurrentStack<Diagnostic> syntaxTreeProcessingMessages)
{
var replacementsDict = new Dictionary<SyntaxNode, SyntaxNode>(0);
var root = (CompilationUnitSyntax)syntaxTree.GetRoot();
foreach (var usingNode in root.DescendantNodes().OfType<UsingDirectiveSyntax>())
{
var ns = usingNode.Name.GetText().ToString();
@aienabled
aienabled / AvoidUnityVisualStudioSolutionRegeneration.cs
Last active Dec 28, 2015
Avoid (re)generation of the Unity VisualStudio solution file for Unity 5.2+
View AvoidUnityVisualStudioSolutionRegeneration.cs
using SyntaxTree.VisualStudio.Unity.Bridge.Configuration;
using UnityEditor;
/// <summary>
/// Avoid (re)generation of the solution file
/// Unfortunately this settings is hidden since Unity 5.2 (when UnityVS was integrated into VS)
/// HOW TO USE: place into your Assets/Editor folder.
/// https://gist.github.com/aienabled/7f6f3f453042ef905ffd
/// </summary>
[InitializeOnLoad]
You can’t perform that action at this time.