Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Working on .NET 6

David Fowler davidfowl

:octocat:
Working on .NET 6
View GitHub Profile
@davidfowl
davidfowl / server.cs
Last active May 15, 2021 — forked from DamianEdwards/server.cs
Simplified ASP.NET Core app exploration
View server.cs
#!/usr/bin/env dotnet run
var builder = WebApplication.CreateBuilder(args);
var config = builder.Configuration;
var connString = config["connectionString"] ?? "Data Source=todos.db";
builder.AddDbContext<TodoDb>(options => options.UseSqlite(connString));
builder.AddSqlite<Todo>(connString) // Higher level API perhaps?
var app = builder.Build();
@davidfowl
davidfowl / trie.js
Last active Dec 19, 2020 — forked from sajclarke/trie.js
Building a trie using Javascript.
View trie.js
const routes = ['/foo/blah/bar', '/foo', '/products']
function buildTrie(routes) {
var root = { path: {} };
for (var route of routes) {
var node = root;
for (var segment of route.split('/')) {
if(segment.length === 0) continue;
if (node.path[segment] == null) {
node.path[segment] = { path: {} };
@davidfowl
davidfowl / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@davidfowl
davidfowl / gist:3173128
Created Jul 24, 2012 — forked from jmangelo/gist:3173109
MethodInfo.Invoke is slow... open instance delegate to the rescue
View gist:3173128
using System;
using System.Linq;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Collections.Generic;
namespace ConsoleApplication3
{
class Program