Skip to content

Instantly share code, notes, and snippets.

William Hallatt williamhallatt

Block or report user

Report or block williamhallatt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@williamhallatt
williamhallatt / logger.ts
Last active Apr 25, 2019
Winston TypeScript Logger
View logger.ts
import * as config from "config";
import { Logger, LoggerInstance, LoggerOptions, transports } from "winston";
require("winston-daily-rotate-file");
const defaultLevel = process.env.LOG_LEVEL;
// We might want to do something on rotation?
// rotateTransport.on("rotate", (oldFilename, newFilename) => {
// // do something fun
// });
View centos7-systemd-docker-demo-dockerfile
FROM centos:7
# This bit is exactly as per the documentation and can be stuck
# existing Dockerfiles without issue
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*; \
@williamhallatt
williamhallatt / ngrxintro.md
Created May 30, 2017 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series
View ngrxintro.md

Comprehensive Introduction to @ngrx/store

By: @BTroncone

Also check out my lesson @ngrx/store in 10 minutes on egghead.io!

Update: Non-middleware examples have been updated to ngrx/store v2. More coming soon!

Table of Contents

@williamhallatt
williamhallatt / cloudSettings
Last active Aug 21, 2019
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2019-08-21T22:23:27.240Z","extensionVersion":"v3.4.2"}
View AuthorisationPolicyConfigureJwtBearer.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// ..........
const string domain = "http://localhost:16137/";
const string secretKey = "needtogetthisfromsomewheresafeandsecure";
var securityKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(secretKey));
var tokenValidationParameters = new TokenValidationParameters
{
View AuthorisationPolicyIndex.html
<!-- There is some style stuff here... -->
<h1>Claims!</h1>
<h2>Valid User With Serious Claims Section</h2>
<div>
<button type="button" onclick="validUserWithSeriousClaimsLogin()">Log in as Valid User With Serious Claims!</button>
</div>
<br />
<div>
<button type="button" onclick="requestValidUserWithSeriousClaimsData()">Request Valid User With Serious Claims data</button>
View AuthorisationPolicyResourceController.cs
[Authorize(Policy = "OnlyValidUsers")]
[Route("api/[controller]/[action]")]
public class ResourceController : Controller
{
[Authorize(Policy = "ValidUserWithSeriousClaims")]
[HttpGet]
public IActionResult ValidUserWithSeriousClaimsData()
{
return new OkObjectResult("Hello Valid User With Serious Claims, " +
"this is your data speaking!");
View AuthorisationPolicyAccountController.cs
[Route("api/[controller]/[action]")]
public class AccountController : Controller
{
private readonly SigningCredentials _signingCredentials;
private readonly JsonSerializerSettings _serializerSettings;
public AccountController()
{
var securityKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes("needtogetthisfromsomewheresafeandsecure"));
_signingCredentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
View ConfigureAuthorisationPolicies.cs
public void ConfigureServices(IServiceCollection services)
{
// ..........
// Set up authorisation policies.
services.AddAuthorization(options =>
{
options.AddPolicy("OnlyValidUsers",
policy =>
{
You can’t perform that action at this time.