Skip to content

Instantly share code, notes, and snippets.

Adam Wright awright18

View GitHub Profile
@awright18
awright18 / program.cs
Last active Sep 20, 2018
Setting Up Serilog with Asp.Net Core
View program.cs
public class Program
{
public IConfiguration Configuration =
new ConfigurationBuilder()
.AddJsonFile("appSettings.json")
.AddEnvironmentVariables()
.AddUserSecrets<StartUp>();
public static Task<int> Main(string[] args)
{
@awright18
awright18 / Web.config App Settings
Last active Sep 14, 2018
Web.Config App Settings
View Web.config App Settings
<AppSettings>
<Add Name="Foo" Value="Bar" />
</AppSettings>
@awright18
awright18 / web.config ConnectionStrings
Last active Sep 14, 2018
.NET Framework Connection String Configuration
View web.config ConnectionStrings
<ConnectionStrings>
<Add name="MyDatabaseConnectionString"
connectionString="Data Source=".";
Initial Catalog="MyDataBase";
Integrated Secruity=true;" />
</ConnectionStrings>
@awright18
awright18 / Result.cs
Created Apr 26, 2018
Functional Result in C#
View Result.cs
using System;
using System.Runtime.InteropServices.ComTypes;
namespace Result
{
public static class Result
{
public static Result<T,TError> Ok<T,TError>(T value)
{
@awright18
awright18 / template.json
Last active Oct 20, 2017
dotnet new template.json intializing a git repository
View template.json
{
"$schema": "http://json.schemastore.org/template",
"author": "Adam",
"classifications": [ "classlib" ],
"name": "My class lib",
"identity": "Adam.ClassLib2.CSharp",
"groupIdentity":"MyClassLib",
"shortName": "MyClassLib", // You can create the project using this short name instead of the one above.
"tags": {
@awright18
awright18 / dotnetlayout.md
Last active Jul 18, 2017 — forked from davidfowl/dotnetlayout.md
.NET project structure
View dotnetlayout.md
$/
  .vscode/
  .fake/
  .nuget/
    nuget.exe
    nuget.config
  .paket/
    paket.bootstrapper.exe
    paket.targets
@awright18
awright18 / NotEnums.cs
Created Jul 11, 2017
A way to avoid having to use enums
View NotEnums.cs
using System;
namespace NotEnums
{
public class Options
{
public string Value { get; private set; }
private const string Option1 = "Option1";
private const string Option2 = "Option2";
@awright18
awright18 / Sample.fsproj
Last active Jul 7, 2017
F# http reqeust with HttpClient
View Sample.fsproj
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="rss.fs" />
View chunkBySizeExample.fs
//chunk records by 100
let longSeq = [1..10000]
let size = 100
let foo (x:IEnumerable<int>) = x |> Seq.iter (fun x -> printf "%i" x)
longSeq |> Seq.chunkBySize size |> Seq.iter (fun seq -> foo seq)
@awright18
awright18 / ProjectChooser.cs
Created Feb 4, 2017 — forked from uluhonolulu/ProjectChooser.cs
Custom VS Project Template Wizard
View ProjectChooser.cs
static class ProjectChooser
{
private static Project _webProject;
public static void FixOutputPath(this Project project) {
var webProject = project.DTE.Solution.FindWebProject();
SetOutputPathTo(project, webProject);
}
public static void AddMvcReference(this Project project) {
You can’t perform that action at this time.