Skip to content

Instantly share code, notes, and snippets.

View brad-jones's full-sized avatar

Brad Jones brad-jones

View GitHub Profile
@brad-jones
brad-jones / index.js
Created November 7, 2017 08:51
Get a list of required polyfill.io features based on browserslist
const semver = require('semver');
const browserslist = require('browserslist');
const polyFillService = require('polyfill-service');
function browserVersionMatches(browsersListVersion, polyFillServiceVersion)
{
// Do some quick and easy checks first
if (browsersListVersion === polyFillServiceVersion) return true;
if (polyFillServiceVersion === '*') return true;
if (browsersListVersion === 'all') return true;
@brad-jones
brad-jones / Dockerfile
Last active September 10, 2020 04:35
buildkit cache reproducer - see: https://github.com/moby/buildkit/issues/723
FROM alpine:latest AS devel
RUN apk --no-cache add git
RUN mkdir /app
RUN touch /app/foo
FROM scratch AS runtime
COPY --from=devel /app/. /app
@brad-jones
brad-jones / login.ps1
Created April 23, 2020 02:04
RDP CLI
cmdkey /generic:"TERMSRV/{{IP_OR_HOSTNAME}}" /user:"{{USERNAME}}" /pass:"{{PASSWORD}}"; mstsc.exe /v:"{{IP_OR_HOSTNAME}}"; cmdkey /delete:"TERMSRV/{{IP_OR_HOSTNAME}}";
@brad-jones
brad-jones / scgi-server.php
Created January 23, 2014 06:24
The SCGI protocol is a replacement for the Common Gateway Interface (CGI) protocol. It is a standard for applications to interface with HTTP servers. It is similar to FastCGI but is designed to be easier to implement. This is a PHP Implementation.
<?php
/**
* Class: MyListener
* =============================================================================
* This sets up the underlying socket server.
* Using all this nice new LibEvent code which is now part of PHP.
*/
class MyListener
{

Keybase proof

I hereby claim:

  • I am brad-jones on github.
  • I am bradjones (https://keybase.io/bradjones) on keybase.
  • I have a public key ASCTchBbxm2cbiSY41DxpQVSFARWzcWGFRZ2FGfuj4_TzQo

To claim this, I am signing this object:

@brad-jones
brad-jones / systemd-boot-kernel-updater
Created June 13, 2018 05:56
Useful for when you want to dual boot with MacOs or not use Grub.
#!/usr/bin/env bash
set -eo pipefail;
echo "Fedora Systemd-Boot Kernel Update Script";
echo "================================================================================";
latestVmlinuz="$(ls -t /boot/vmlinuz* | head -1)";
latestVersion="$(echo $latestVmlinuz | sed -e 's~/boot/vmlinuz-~~' -e 's~.x86_64~~')";
echo "Installing latest kernel ($latestVersion) into systemd-boot";
@brad-jones
brad-jones / post.md
Created June 4, 2018 02:40
Get GOing with golang

Get GOing with golang

After initially starting with golang, I found it very refreshing, it's super fast, has a great supportive toolset, fantatsic IDE integrations, super duper easy cross compilation and so on.

After some time though, especially after building some more complex apps and libraries, I started to feel like I was in a giant mess of go code, sure it worked but many of the princiapls that have been so foundational in other languages, like loose coupling, dependency injection, inversion of control, even simple things like package structure and namespacing seem to have

@brad-jones
brad-jones / transpile.ts
Created October 11, 2017 00:41
ts-simple-ast script to add real reflection to typescript/javascript
import * as ts from 'typescript';
import TsSimpleAst, { TypeGuards, GetAccessorDeclaration, SetAccessorDeclaration, PropertyDeclaration, Type, TypeNode, Node, TypedNode, Scope } from "ts-simple-ast";
let ast = new TsSimpleAst
({
tsConfigFilePath: __dirname + '/tsconfig.options.json',
compilerOptions: { outDir: __dirname + '/dist' }
});
ast.addSourceFiles(__dirname + '/src/**/*{.d.ts,.ts}');
@brad-jones
brad-jones / test.cs
Created September 5, 2017 23:00
Intial setup for RazorLight dotnet 2.0
using System;
using Xunit;
using Microsoft.AspNetCore.Razor.Language;
using Microsoft.AspNetCore.Razor.Language.Extensions;
using Microsoft.Extensions.PlatformAbstractions;
using Microsoft.AspNetCore.Mvc.Razor.Extensions;
namespace Tests.Razor
{
public class RazorTests
@brad-jones
brad-jones / Dockerfile
Created April 10, 2017 12:57
docker-dotnet-vscode
FROM microsoft/dotnet:latest
# Install Node.js repo
RUN curl -sL https://deb.nodesource.com/setup_7.x | bash -
# Install the VsCode repo
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg && \
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg && \
echo "deb [arch=amd64] http://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list