Skip to content

Instantly share code, notes, and snippets.

View jessenich's full-sized avatar
😶‍🌫️
I may be slow to respond.

Jesse N. jessenich

😶‍🌫️
I may be slow to respond.
View GitHub Profile
@jessenich
jessenich / JsonNetSerializer.cs
Last active August 1, 2021 17:55
To use Newtonson JSON Converter with RestSharp
using RestSharp.Deserializers;
using RestSharp.Serializers;
namespace RestSharp.Serialization
{
public interface IRestSerializer : ISerializer, IDeserializer
{
string[] SupportedContentTypes { get; }
DataFormat DataFormat { get; }
/*
* There is a colony of 8 cells arranged in a straight line where each day every cell competes with
* its adjacent cells(neighbour). Each day, for each cell, if its neighbours are both active or both
* inactive, the cell becomes inactive the next day, otherwise it becomes active the next day.
*
* Assumptions
* The two cells on the ends have single adjacent cell, so the other adjacent cell can be assumsed to
* be always inactive. Even after updating the cell state. consider its previous state for updating the
* state of other cells. Update the cell information of all cells simultaneously.
*
using System;
namespace AmazonAssessment
{
public static class GCD
{
public static void Run()
{
Console.WriteLine(Solution(new int[] { 36, 48, 1152 }, 24));
}
@jessenich
jessenich / ARPReader.cs
Last active August 8, 2020 04:47
C# ARP Reader
// Written in 2013
// Not tested since .NET Framework 4
using System;
using System.Collections.Generic;
using System.Net;
using System.Runtime.InteropServices;
public class ARP
{
@jessenich
jessenich / sqlite3reader.cs
Last active August 17, 2021 18:25
C# Dependency free sqlite3 reader
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualBasic;
using Microsoft.VisualBasic.CompilerServices;
using System.Runtime.InteropServices;
public static string ReplaceDiacritics(this string str)
{
string stringFormD = str.Normalize(NormalizationForm.FormD);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < stringFormD.Length; i++)
{
UnicodeCategory unicodeChar = CharUnicodeInfo.GetUnicodeCategory(stringFormD[i]);
if (unicodeChar != UnicodeCategory.NonSpacingMark)
sb.Append(stringFormD[i]);
@jessenich
jessenich / AutoMigration.cs
Last active December 25, 2020 22:31 — forked from lakeman/AutoMigration.cs
Automatic database migration with EF Core 3.0
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Storage;
using System;
using System.IO;
using System.Text;
public class ASCII85
{
/// <summary>
/// Prefix mark that identifies an encoded ASCII85 string, traditionally '<~'
/// </summary>
public string PrefixMark = "<~";
@jessenich
jessenich / Open in Visual Studio Code
Last active December 25, 2020 22:29
Mac OS X Open in VSCode
- Open Automator
- File -> New -> Service
- Change "Service Receives" to "files or folders" in "Finder"
- Add a "Run Shell Script" action
- Change "Pass input" to "as arguments"
- Paste the following in the shell script box: open -n -b "com.microsoft.VSCode" --args "$*"
- use "com.microsoft.VSCodeInsiders" for insiders edition
- Save it as something like "Open in Visual Studio Code"
@jessenich
jessenich / powershell.ps1
Last active June 5, 2024 00:18
GH CLI PowerShell Completions
using namespace System.Management.Automation
using namespace System.Management.Automation.Language
Register-ArgumentCompleter -Native -CommandName 'gh' -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$commandElements = $commandAst.CommandElements
$command = @(
'gh'
for ($i = 1; $i -lt $commandElements.Count; $i++) {
$element = $commandElements[$i]
if ($element -isnot [StringConstantExpressionAst] -or