Skip to content

Instantly share code, notes, and snippets.

@jackinf
jackinf / __logging-and-monitoring-using-seq.md
Last active October 29, 2019 12:07
Logging, Monitoring, Stackdriver, Seq

Seq

Running Seq instance

docker run \
  -e ACCEPT_EULA=Y \
  -v /tmp/seqdb:/data \
  -p 80:80 \
  -p 5341:5341 \
 datalust/seq:latest
@jackinf
jackinf / circleci-config.yml
Last active January 6, 2019 17:42
CircleCI simple configuration for building and pushing Docker image
# .circleci/config.yml should be in the root of the project
version: 2
general:
branches:
only:
- develop
- master
jobs:
build:
machine: true
@jackinf
jackinf / apollo-neo4j.js
Last active December 29, 2018 14:04
Apollo helpers
const { v1: neo4j } = require('neo4j-driver')
const { ApolloServer, makeExecutableSchema } = require('apollo-server')
const driver = neo4j.driver(
`bolt://${process.env.NEO4J_HOST}:7687`,
neo4j.auth.basic(process.env.NEO4J_USER, process.env.NEO4J_PASS))
const typeDefs = `
type Person { name: String! }
type Planet { name: String! }
function urlB64ToUint8Array(base64String) {
const padding = '='.repeat((4 - base64String.length % 4) % 4);
const base64 = (base64String + padding)
.replace(/\-/g, '+')
.replace(/_/g, '/');
const rawData = window.atob(base64);
const outputArray = new Uint8Array(rawData.length);
for (let i = 0; i < rawData.length; ++i) {

Certificates

Generate certificates

#!/bin/bash

LOCATION=${1:-'/tmp'}

# Files required by nginx proxy
@jackinf
jackinf / sqrt-memoization.js
Created November 26, 2018 10:27
JS: Memoization example
function memoize(fn) {
return function() {
const args = Array.prototype.slice.call(arguments);
fn.cache = fn.cache || {};
return fn.cache[args]
? fn.cache[args]
: (fn.cache[args] = fn.apply(this, args));
};
}
@jackinf
jackinf / app.jsx
Created November 5, 2018 11:03
React context
import {ThemeContext, themes} from './theme-context';
import ThemedButton from './themed-button';
// An intermediate component that uses the ThemedButton
function Toolbar(props) {
return (
<ThemedButton onClick={props.changeTheme}>
Change Theme
</ThemedButton>
);
}
@jackinf
jackinf / index.html
Created November 5, 2018 10:59
React hello world in 1 file - simplest example.
<html>
<head>
<script src="https://unpkg.com/react@15/dist/react.min.js"> </script><script src="https://unpkg.com/react-dom@15/dist/react-dom.min.js">
</script>
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
@jackinf
jackinf / power-options.bat
Created October 29, 2018 09:41
Windows 10 - change power settings
# Thanks to https://stackoverflow.com/questions/15455864/powershell-set-lid-close-action/21634858#21634858
# When closing the lid...
# ...set the option to do nothing when plugged in
powercfg -setacvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0
# ...set the option to do nothing when using the battery
powercfg -setdcvalueindex 381b4222-f694-41f0-9685-ff5bb260df2e 4f971e89-eebd-4455-a8de-9e59040e7347 5ca83367-6e45-459f-a27b-476b1d01c936 0
@jackinf
jackinf / index.jsx
Created October 6, 2018 13:27
React create app (Redux etc)
import React from 'react'
import { render } from 'react-dom'
import { Provider } from 'react-redux'
import { ConnectedRouter } from 'connected-react-router'
import store, { history } from './store'
import App from './containers/app'
import 'sanitize.css/sanitize.css'
import './index.css'