Skip to content

Instantly share code, notes, and snippets.

View JeremyLikness's full-sized avatar

Jeremy Likness JeremyLikness

View GitHub Profile
@JeremyLikness
JeremyLikness / Program.cs
Created June 17, 2022 16:08
Example of repo with "open" IQueryable
using Example;
using Microsoft.EntityFrameworkCore;
var repo = new ThingRepo();
repo.Init();
var cyanShapes = repo.GetThings(
q => q.Where(
q => q.Name.Contains(nameof(ConsoleColor.Cyan)))
.OrderByDescending(s => s.Size));
@JeremyLikness
JeremyLikness / ApplicationCosmosDbContext.cs
Created May 14, 2020 04:25
A custom identity context to intercept user adds
using BlazorCosmosWasm.Server.Controllers;
using BlazorCosmosWasm.Server.Models;
using BlazorCosmosWasm.Shared;
using IdentityServer4.EntityFramework.Options;
using Microsoft.Azure.Cosmos;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using System.Diagnostics;
using System.Linq;
@JeremyLikness
JeremyLikness / Program.cs
Created June 15, 2021 16:28
Using expressions for comparisons
using System;
using System.Linq.Expressions;
namespace expressioncompare
{
class Program
{
static void Main(string[] args)
{
var left = Expression.Parameter(typeof(int), "left");
@JeremyLikness
JeremyLikness / Program.cs
Created November 2, 2020 17:28
StrawberryShake errors
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
namespace EFCoreContributors
{
public class Program
{
private const string PAT = "xyz";
@JeremyLikness
JeremyLikness / CosmosExtensions.cs
Created May 14, 2020 04:22
Cosmos extensions for the server
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using IdentityServer4.Extensions;
using Microsoft.AspNetCore.Identity;
using BlazorCosmosWasm.Server.Models;
using Microsoft.Azure.Cosmos;
using Microsoft.Extensions.Configuration;
namespace BlazorCosmosWasm.Server.Controllers
@JeremyLikness
JeremyLikness / Program.cs
Created May 26, 2020 17:19
An example of LINQ at work
using System;
using System.Collections.Generic;
using System.Linq;
namespace linqexample
{
public class Thing
{
private static int NextInt = 1;
public override async Task<AddressBookList> GetAddressBookAsync(Empty request,
ServerCallContext context)
{
var objPersons = new AddressBookList();
var peopleWithPhoneNumbers = await _dataContext.People
.Include(p => p.Phones)
.AsNoTracking()
.ToListAsync();
@JeremyLikness
JeremyLikness / BlogClient.cs
Created May 14, 2020 04:29
A blog client that retries credentials
using BlazorCosmosWasm.Shared;
using Microsoft.EntityFrameworkCore;
using System;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;
namespace BlazorCosmosWasm.Client.Data
{
public class BlogClient : IBlogClient
@JeremyLikness
JeremyLikness / CosmosController.cs
Created May 14, 2020 04:23
Cosmos token controllerr
using System.Threading.Tasks;
using IConfiguration = Microsoft.Extensions.Configuration.IConfiguration;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Cosmos;
using BlazorCosmosWasm.Shared;
using Microsoft.AspNetCore.Identity;
using BlazorCosmosWasm.Server.Models;
namespace BlazorCosmosWasm.Server.Controllers
@JeremyLikness
JeremyLikness / main.wat
Created February 11, 2020 22:49
WASI "Hello, World"
(module
(type $t0 (func (param i32 i32 i32 i32) (result i32)))
(type $t1 (func))
(import "wasi_unstable" "fd_write" (func $fd_write (type $t0)))
(func $main (type $t1)
i32.const 0
i32.const 8
i32.store
i32.const 4
i32.const 22