Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Alloway danalloway

View GitHub Profile
@danalloway
danalloway / ActivityProvider.js
Last active Jul 9, 2019
React Providers using Context / State / Hooks
View ActivityProvider.js
/**
* 1.) Context. For lifting our state up to any tree below the Provider.
*/
const ActivityContext = createContext()
/**
* 2.) Provider. For sharing our state across many render trees.
*/
export const ActivityProvider = ({ children }) => {
const [activity, setActivity] = useState([])
View hocClassBoilerplate.js
import React from "React"
import hoistNonReactStatic from "hoist-non-react-statics"
const withHOC = hocProps => WrappedComponent => {
// use `hocProps` to configure how the HOC behaves towards it's `WrappedComponent`
const { debug } = hocProps
if (debug) {
console.debug("withHoc is in DEBUG mode")
}
@danalloway
danalloway / font-awesome.js
Created Apr 7, 2018
FontAwesome v5 Component I'm using with Preact
View font-awesome.js
import { h, createElement } from 'preact'
import humps from 'humps'
import fontawesome from '@fortawesome/fontawesome'
// icons
import faClipboardList from '@fortawesome/fontawesome-pro-solid/faClipboardList'
import faPlus from '@fortawesome/fontawesome-pro-solid/faPlus'
fontawesome.library.add(faClipboardList, faPlus)
const Icon = props => {
@danalloway
danalloway / PersistGate.js
Created Nov 20, 2017
redux-persist PersistGate component for Preact
View PersistGate.js
import { h, Component } from 'preact';
export default class PersistGate extends Component {
unsubscribe;
state = {
isBootstrapped: false
};
handlePersistorState = () => {
@danalloway
danalloway / app.js
Last active Nov 7, 2017
preact, redux, react-router-redux SSR
View app.js
import { h } from 'preact';
import Link from 'react-router-dom/Link';
import Route from 'react-router-dom/Route';
import Switch from 'react-router-dom/Switch';
import Home from '../routes/Home';
import About from '../routes/About';
const App = () => (
<div>
View keybase.md

Keybase proof

I hereby claim:

  • I am danalloway on github.
  • I am danalloway (https://keybase.io/danalloway) on keybase.
  • I have a public key ASCwi8A8WbtHO1dOgZmOJo4jdOcqjrSK5yBOQ05-xrNyGQo

To claim this, I am signing this object:

@danalloway
danalloway / 503.nginx
Created Feb 16, 2016
Custom NGINX 503 Page
View 503.nginx
server {
server_name _;
# override how 503's should be handled
error_page 503 @503;
location @503 {
# attempt to server our custom 503 first
# then fall back to the built-in one
try_files /503.html =503;
@danalloway
danalloway / dst.js
Last active Mar 1, 2020
Calculate DST in Javascript
View dst.js
/**
* Daylight Savings Time
*
* Since 2007 DST begins on the second sunday of March,
* and ends on the first sunday of November.
*
* @see http://www.nist.gov/pml/div688/dst.cfm
* @author Dan Alloway <dan@micahsix.com>
*/
@danalloway
danalloway / ssl.nginxconf
Last active May 15, 2017
Force full, secure SSL configuration on an NGINX site.
View ssl.nginxconf
# capture HTTP requests to example.com and www.example.com
# and permanently redirect them to the HTTPS version of the site
#
server {
listen 80; # IPv4
listen [::]:80; # IPv6
server_name example.com www.example.com;
@danalloway
danalloway / bitcoin.conf
Last active Feb 10, 2018
My Bitcoin & P2Pool Configuration files.
View bitcoin.conf
server=1
daemon=1
rpcuser=
rpcpassword=
blockmaxsize=1000000
mintxfee=0.00001
minrelaytxfee=0.00001
You can’t perform that action at this time.