Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
public static class ConfigExtensions
{
@scottgal
scottgal / File Translator
Last active July 20, 2023 11:32
EasyNMT Json File Translator
// https://github.com/UKPLab/EasyNMT/blob/main/docker/README.md
// See https://aka.ms/new-console-template for more information
using System.Net.Http.Json;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
@scottgal
scottgal / StringWithoutSpaceBenchmark.cs
Created October 2, 2022 11:52
StringNoSpaceCount Benchmarks
using System.Text.RegularExpressions;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Microsoft.VisualBasic;
BenchmarkRunner.Run<StringyBench>();
[MemoryDiagnoser]
public class StringyBench
{
@scottgal
scottgal / k6FileOutput.js
Last active October 1, 2022 17:10
k6 with custom file bundle
//xk6 build v0.40.0 --with github.com/avitalique/xk6-file
//k6 run the-best-tests.js -e OUT_FILE="./log_$(((get-date).ToUniversalTime()).ToString("yyyyMMddTHHmmssZ")).txt"
import { SharedArray } from 'k6/data';
import { scenario } from 'k6/execution';
import { check, fail }from 'k6'
import http from 'k6/http';
import { URL } from 'https://jslib.k6.io/url/1.0.0/index.js';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
import file from 'k6/x/file';
const textData = new SharedArray('AddressData', function () {
@scottgal
scottgal / k6LogRequests.js
Created October 1, 2022 16:03
K6LogRequests
import { SharedArray } from 'k6/data';
import { scenario } from 'k6/execution';
import { check, fail }from 'k6'
import http from 'k6/http';
import { URL } from 'https://jslib.k6.io/url/1.0.0/index.js';
import { randomIntBetween } from 'https://jslib.k6.io/k6-utils/1.2.0/index.js';
const textData = new SharedArray('AddressData', function () {
return open('./outfile_en_GB.txt').split(/\r?\n/);
});
export const options = {
@scottgal
scottgal / ViewHelpers.cs
Created March 1, 2021 16:30
ASP.NET MVC Bundle Helper
using System;
using System.Configuration;
using System.IO;
using System.Web;
using System.Web.Caching;
using System.Web.Hosting;
using System.Web.Mvc;
using Shared.Web.Models;
namespace Helpers

Keybase proof

I hereby claim:

  • I am scottgal on github.
  • I am scottgal (https://keybase.io/scottgal) on keybase.
  • I have a public key whose fingerprint is 5C60 05D3 C084 06BC 03AC 7A7D 18D2 63B4 E992 A906

To claim this, I am signing this object:

@scottgal
scottgal / Dockerfile
Created March 15, 2019 12:14
Sample VS 2019 16.0.0.RC.2 Dockerfile
FROM microsoft/dotnet:3.0-aspnetcore-runtime-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM microsoft/dotnet:3.0-sdk-stretch AS build
WORKDIR /src
COPY ["WebApplication1/WebApplication1.csproj", "WebApplication1/"]
RUN dotnet restore "WebApplication1/WebApplication1.csproj"
COPY . .
public static class EnumHelper
{
public static string Name(this Enum enumType)
{
var typeOfEnum = enumType.GetType();
return Enum.GetName(typeOfEnum, enumType);
}
public static string[] Names<T>()
{
@scottgal
scottgal / gist:e263ab6d7de7bc517c81
Created March 10, 2015 03:23
EF Why can't you do this?
public class Parent
{
public List<string> ItemIds
{
get;
set;
}
///WHY CAN'T EF HANDLE THIS SO I CAN JUST HANDLE ITEMIDS ON UPDATE OF PARENT RATHER THAN LOAD THEM ALL TO KEEP THE RELATIONSHIP?
[ForeignKeys("ItemIds")]