Skip to content

Instantly share code, notes, and snippets.

View oscarduignan's full-sized avatar
🐢
Catching up

Oscar Duignan oscarduignan

🐢
Catching up
View GitHub Profile
@oscarduignan
oscarduignan / Caddyfile
Last active July 3, 2024 09:47
Example showing how default platform CSP is incompatible with some ways of loading scripts
http://127.0.0.1 {
vars {
platformCSP "script-src 'nonce-abc123' 'unsafe-inline' 'strict-dynamic' https: http: ; object-src 'none'; base-uri 'none';"
}
route / {
header Content-Type text/html
header Content-Security-Policy {vars.platformCSP}
respond <<HTML
<html>
const NON_DIGITS_OR_SPACES = /[^0-9 ]+/g;
const SPACES_OTHER_THAN_SINGLE_TRAILING = / (?!$)/g;
// could do it in one regex but then "1234 a" will be "1234" rather than "1234 "
// const NON_DIGITS_EXCEPT_SINGLE_TRAILING_SPACE = /[^0-9 ]+| (?!$)/g;
const maskCreditCardNumber = (value) => {
return (
value
.replace(NON_DIGITS_OR_SPACES, "")
@oscarduignan
oscarduignan / README.md
Last active December 5, 2017 02:14
Connect to NordVPN more easily on linux (using fish shell, fzf, and fd - gif of finished script in comments)

Assuming you have openvpn, fish, fzf, and fd installed

Grab the NordVPN openvpn config files and unzip them

curl -Lo ~/NordVPN/ovpn.zip --create-dirs https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip
unzip ~/NordVPN/ovpn.zip

Grab the function defined in the file below

@oscarduignan
oscarduignan / commandbox_overlay.nix
Last active October 12, 2017 16:34
nixos package and an overlay that uses it to install commandbox (command line tool for the lucee cfml programming language)
self: super: {
commandbox = super.callPackage /path/to/commandbox_package {};
}
@oscarduignan
oscarduignan / latest_docker_compose.nix
Last active October 11, 2017 13:06
Get the latest version of docker-compose with nixpkgs which requires overriding texttable dependency version (using overlays)
self: super:
let
docker_compose = super.docker_compose.override (oldAttrs: {
texttable = super.python.pkgs.buildPythonPackage rec {
name = "texttable-0.9.1";
src = super.fetchurl {
url = "mirror://pypi/t/texttable/${name}.tar.gz";
sha256 = "119041773ff03596b56392532f9315cb3a3116e404fd6f36e76a7dc088d95c79";
@oscarduignan
oscarduignan / config.nix
Created October 11, 2017 09:27
Get the latest version of docker-compose with nixpkgs which requires overriding texttable dependency version
{
packageOverrides = pkgs: with pkgs; rec {
docker_compose = pkgs.docker_compose.override (oldAttrs: {
texttable = python.pkgs.buildPythonPackage rec {
name = "texttable-0.9.1";
src = fetchurl {
url = "mirror://pypi/t/texttable/${name}.tar.gz";
sha256 = "119041773ff03596b56392532f9315cb3a3116e404fd6f36e76a7dc088d95c79";
};
@oscarduignan
oscarduignan / boxstarter.ps1
Created September 27, 2017 08:50
A basic boxstarter install script
# install a program with chocolatey
choco install googlechrome
# update behaviour of file explorer
Set-WindowsExplorerOptions -EnableShowHiddenFilesFoldersDrives -EnableShowProtectedOSFiles -EnableShowFileExtensions
# remove a store-installed program
Get-AppxPackage *Facebook* | Remove-AppxPackage
# lock screen when you close your laptop rather than sleeping it
@oscarduignan
oscarduignan / keybase.md
Created February 18, 2016 10:32
keybase.md

Keybase proof

I hereby claim:

  • I am oscarduignan on github.
  • I am oscarduignan (https://keybase.io/oscarduignan) on keybase.
  • I have a public key ASDe23XSQ0QeZQ7J2cA6-Ou8wRVyt-pBcUkuSnv0o7fxngo

To claim this, I am signing this object:

@oscarduignan
oscarduignan / gist:c4e8fc7738c69a21f32a
Created July 10, 2015 20:47
webpack dev server config to go ina gulp file... issue is that I forgot that this does live reload for everything but the html which I'm compiling separately so that's why I need browser-sync
var WEBPACK_PORT = process.env.WEBPACK_PORT || 8080;
new WebpackDevServer(webpack, {
hot: true,
inline: true,
contentBase: path.resolve(__dirname, 'dist'),
progress: true,
stats: {
colors: require('supports-color'),
chunks: false
@oscarduignan
oscarduignan / gist:c79aab79b3ff69b52ee7
Last active July 1, 2016 18:09
Outline of pattern for building stuff with RxJS and React. Originally at http://jsbin.com/jelale/edit?js and mirrored here to make it clearer that it's not currently supposed to be executable!
/*
OUTLINE FOR AN APP BUILT WITH RXJS AND REACT, USING AN ELASTICSEARCH FACETED SEARCH
MODULE AS AN EXAMPLE, READ FROM BOTTOM UP IF YOU WANT TO GO OUTSIDE IN, START FROM
TOP TO SEE HOW THE SEARCH MODULE IS COMPOSED.
If you find this I would love to hear some feedback - it's not designed to work without
any modification though, it's just supposed to outline the architecture off-the-top-of-
my-head-pretty-close-to-working psuedocode of something that you might actually need to
build to drive out if the pattern is any good!
*/