Skip to content

Instantly share code, notes, and snippets.

View jstclair's full-sized avatar

John St. Clair jstclair

View GitHub Profile
@jstclair
jstclair / Program.cs
Created November 18, 2020 10:29
Commented demo for using System.Threading.Channels
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Threading.Channels;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
namespace ChannelsDemo
{
@jstclair
jstclair / tokeninstaller.cs
Last active December 28, 2020 07:10
Example of wrapping IdentityServer token client with caching
using System.Net.Http.Headers;
using System.Threading;
using System.Threading.Tasks;
using Api.Services;
using IdentityModel.Client;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
@jstclair
jstclair / project.lock.json
Created September 28, 2015 13:54
Kestrel issue #226
{
"locked": false,
"version": 2,
"targets": {
"DNXCore,Version=v5.0": {
"Microsoft.AspNet.Antiforgery/1.0.0-beta8-15653": {
"type": "package",
"dependencies": {
"Microsoft.AspNet.DataProtection": "1.0.0-beta8-15615",
"Microsoft.AspNet.Http.Abstractions": "1.0.0-beta8-15630",
@jstclair
jstclair / .gitconfig-aliases
Created September 3, 2015 11:21
Git aliases
[alias]
# common aliases - acquired from many places...
# operations
b = branch
cl = clone
ci = commit
amend = commit --amend --no-edit
st = status --short --branch
@jstclair
jstclair / main.scss
Created April 10, 2015 14:21
background-image-shading
body, html {
background: linear-gradient(
rgba(0, 0, 0, 0.6),
rgba(0, 0, 0, 0.6)
),
url(/assets/images/inspiring-cafe-interior-of-despresso-library.jpg) top left no-repeat;
background-size: cover;
background-attachment: fixed;
}
@jstclair
jstclair / bookPileActions.js
Created March 25, 2015 08:16
analytics-in-flux
loadOneAction(context, payload, done) {
//NOTE: This really requires a check that loadAll has completed.
// So something like context.ensure('LOAD_BOOKPILES_SUCCESS')...
//NOTE: called from the router, so route info is passed on .params
return loadData(function(err) {
console.log(err);
context.dispatch('LOAD_BOOKPILES_ERROR', {});
@jstclair
jstclair / .gitconfig
Created December 9, 2010 12:13
My gitconfig
[core]
autocrlf = false
editor = n.exe
excludesfile = C:/Users/johns/.gitignore
[color]
ui = auto
status = auto
diff = auto
branch = auto
[user]
@jstclair
jstclair / gist:707017
Created November 19, 2010 19:35
How to get a UTF8Encoder with a BOM
using System;
using System.Linq;
using System.Text;
namespace BomEncoding
{
class Program
{
static void Main(string[] args)
{
// re-factored as extension methods on user; updated Sold to use named-args as well
var transactions = new[]
{
theUser.StartedOn(monday),
theUser.Bought(2000, of: AYB, @for: 1980, on:tuesday),
theUser.Bought(3000, of: AYB, @for: 3204, on:tuesday),
theUser.Sold(1500, of: AYB, @at:1750, on:wednesday),
theUser.Bought(5000, of:AIK, @for:10000, on:wednesday),
theUser.Bought(4000, of:AKVA, @for: 40000, on:thursday),