Skip to content

Instantly share code, notes, and snippets.

View antmdvs's full-sized avatar

Tony Davis antmdvs

View GitHub Profile
// https://medium.com/asos-techblog/testing-authorization-scenarios-in-asp-net-core-web-api-484bc95d5f6f
// https://github.com/dylan-asos/netcore-authz-inmemory-bddfy/blob/master/src/Asos.DotNetCore.Auth.Api.ComponentTests/BearerTokenBuilder.cs
using Microsoft.IdentityModel.Tokens;
using System;
using System.Collections.Generic;
using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Security.Claims;
using System.Security.Cryptography.X509Certificates;

sam build was resulting in this error:

Building codeuri: C:\code\AwsToolkitJava runtime: None metadata: {'DockerTag': 'java11-maven-v1', 'DockerContext': 'C:\\code\\AwsToolkitJava\\HelloWorldFunction', 'Dockerfile': 'Dockerfile'} functions: ['HelloWorldFunction']
Building image for HelloWorldFunction function
Setting DockerBuildArgs: {} for HelloWorldFunction function
Step 1/10 : FROM amd64/maven as build-image
 ---> 0615804734cc
Step 2/10 : WORKDIR "/task"
 ---> Using cache
@antmdvs
antmdvs / README.md
Last active May 2, 2021 17:49
Modifying Machine-Scoped Path Environment Variable
@antmdvs
antmdvs / FeatureAContextProvider.cs
Last active February 19, 2020 13:11
HttpContext "Decoraptor" for ASP.NET MVC 5 - https://blog.ploeh.dk/2014/08/24/decoraptor/
public class FeatureAContextProvider : IFeatureContextProvider<FeatureAContext>
{
private readonly HttpContextBase _httpContext;
public FeatureAContextProvider(HttpContextBase httpContext)
{
// this would be a "decoraptor" (in quotes because it's wrapping ambient context 🤢)
_httpContext = httpContext;
}
@antmdvs
antmdvs / Startup.cs
Last active February 14, 2020 18:23
Configure Patterns
// KISS
services.AddMyService(sdkKey);
// builder
services.AddMyService(config => config.UseSdkKey(sdkKey));
// fluent
services.AddMyService()
.UseSdkKey(sdkKey);
@antmdvs
antmdvs / PalindromeChecker.cs
Last active March 27, 2019 15:51
Palindromes in C# 7. Test-driven using xUnit
// This code is API-compatible with .NET Standard 1.2.
// https://docs.microsoft.com/en-us/dotnet/standard/net-standard#which-net-standard-version-to-target
using System;
using System.Linq;
namespace Palindrome
{
public class PalindromeChecker : IPalindromeChecker
{
@antmdvs
antmdvs / solution.js
Last active November 12, 2018 14:25
Product filtering
//Installed node modules: jquery underscore request express jade shelljs passport http sys lodash async mocha moment connect validator restify ejs ws co when helmet wrench brain mustache should backbone forever debug
process.stdin.resume();
process.stdin.setEncoding('utf8');
var util = require('util');
var input = "";
process.stdin.on('data', function (text) {
input += text;
});
@antmdvs
antmdvs / ReactHooks.code-snippets
Last active November 7, 2018 17:51
Snippets for React's *EXPERIMENTAL* `useState()` hook -- See https://reactjs.org/hooks
{
"useState()": {
"prefix": "us",
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"body": [
"const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState($2);",
"$0"
],
"description": "React: useState()"
},

Discoverability: Strive for 1 type per file.

DO:

Foo.cs:

public class Foo {}

DON'T:

@antmdvs
antmdvs / considerations.md
Last active December 8, 2016 22:48
React Component Selection Considerations

Footprint

  1. What’s the minified bundle size of the component/library?
  2. For a given component library, can we just import a single module if we only need that one component?

import { Component1 } from ‘widgets/libs/component1’;

instead of

import * as components from ‘widgets’;