Skip to content

Instantly share code, notes, and snippets.

@Tewr
Tewr / TestingLinqSerializer.cs
Last active October 15, 2019 08:42
Testing Serialize.Linq for remoting proxy
using Newtonsoft.Json;
using Serialize.Linq.Extensions;
using Serialize.Linq.Nodes;
using System;
using System.Linq.Expressions;
namespace TestingLinqSerializer
{
class Program
{
@Tewr
Tewr / AssemblyProduct.ps1
Created October 8, 2019 05:24
Azure devops: Put git source version and build date in AssemblyProduct
# $Env:SubDirectoryFilter is a custom parameter
$searchPath = "$Env:BUILD_SOURCESDIRECTORY\$Env:SubDirectoryFilter"
$shortCommit = "$Env:BUILD_SOURCEVERSION".Substring(0, 8)
$shortCommit = "@$shortCommit"
$date = [System.DateTime]::Now.ToString("s")
Write-Host "Searching in $searchPath"
Get-ChildItem -Path $searchPath -Recurse -Filter "AssemblyInfo.*" | foreach {
$file = $_.FullName
@Tewr
Tewr / Find what.Regex
Created August 20, 2019 13:39
Visual studio INotifyPropertyChanged Regex
public ([^\s ]+) ([^\s]+) { get; set; }
@Tewr
Tewr / Program.cs
Created April 1, 2019 10:04
Reflection-based console app to call and debug simple task-based api's
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace Good_Gaz.Services.SirsConsoleClient
{
@Tewr
Tewr / MappingExtensions.cs
Created March 26, 2019 12:50
Provides object extensions Map and Tap. Like LINQ Select, but for non-collections. int.Parse("5") becomes "5".Map(int.Parse).
public static class MappingExtensions
{
/// <summary>
/// Applies the specified <paramref name="transformation"/> on the <paramref name="source"/>.
/// </summary>
/// <typeparam name="TSource"></typeparam>
/// <typeparam name="T"></typeparam>
/// <param name="source"></param>
/// <param name="transformation"></param>
/// <returns></returns>
@Tewr
Tewr / Startup.cs
Created March 8, 2019 09:35
Adds Enums to swashbuckle for use with NSwag
/* Source: https://github.com/domaindrivendev/Swashbuckle/issues/1287 */
(...)
config.AddSwaggerGen(options => {
options.DocumentFilter<SwaggerAddEnumDescriptions>();
}
#%HOMEPATH%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
function gitpushup { git rev-parse --abbrev-ref HEAD | foreach { git push --set-upstream origin $_ }}
set-alias git-pushup gitpushup
function gitmergedev { git rev-parse --abbrev-ref HEAD | foreach { if (git checkout develop) {git pull; git checkout $_;git merge develop; }}}
set-alias git-mergedev gitmergedev
function gitmergemas { git rev-parse --abbrev-ref HEAD | foreach { if (git checkout master) {git pull; git checkout $_;git merge master; }}}
set-alias git-mergemas gitmergemas
@Tewr
Tewr / StateChecker.cs
Created November 8, 2018 20:11
Entity framework 6 graph update
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Validation;
using System.Linq;
public interface IEntity
{
int Id { get; set; }
}
@Tewr
Tewr / EmptyReadOnlyDictionary.cs
Last active June 4, 2018 11:58
ReadOnly Empty Dictionary implementation
using System.Linq;
namespace System.Collections.Generic
{
public class EmptyReadOnlyDictionary<TKey, TValue> : IReadOnlyDictionary<TKey, TValue>
{
private static readonly Lazy<IEnumerable<KeyValuePair<TKey, TValue>>> Empty =
new Lazy<IEnumerable<KeyValuePair<TKey, TValue>>>(Enumerable.Empty<KeyValuePair<TKey, TValue>>);
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() => Empty.Value.GetEnumerator();
@Tewr
Tewr / MessageBoxWithCheckBox.Designer.cs
Last active November 18, 2021 18:27
Winforms MessageBoxWithCheckBox
namespace CustomMessageBoxes
{
partial class MessageBoxWithCheckBox
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>