Skip to content

Instantly share code, notes, and snippets.

@dzjack
dzjack / deploy.bash
Created February 19, 2019 21:30 — forked from soarez/deploy.bash
#!/bin/bash
function deploy {
# Update the rsync target on the server
rsync \
-av \
--delete \
--delete-excluded \
$rsync_ignore_list_param \
$rsync_source/ $target:$rsync_target
@dzjack
dzjack / ca.md
Created February 19, 2019 21:29 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@dzjack
dzjack / nextjs-hoc-authorization.js
Created January 28, 2019 12:56 — forked from whoisryosuke/nextjs-hoc-authorization.js
ReactJS - NextJS - A HOC for wrapping NextJS pages in an authentication check. Checks for getInitialProps on the child component and runs it, so you still get SSR from the page. Also includes a user agent for Material UI.
import React, {Component} from 'react'
import Router from 'next/router'
import AuthService from './AuthService'
export default function withAuth(AuthComponent) {
const Auth = new AuthService('http://localhost')
return class Authenticated extends Component {
static async getInitialProps(ctx) {
// Ensures material-ui renders the correct css prefixes server-side
@dzjack
dzjack / graphql_example.py
Created December 27, 2018 11:54 — forked from gbaman/graphql_example.py
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
@dzjack
dzjack / 01_basic.go
Created December 10, 2018 09:03 — forked from reagent/00_README.md
Custom HTTP Routing in Go
package main
import (
"io"
"log"
"net/http"
)
func main() {
@dzjack
dzjack / hoc-template.tsx
Created November 25, 2018 13:40 — forked from devdoomari3/hoc-template.tsx
Typescript higher order component (hoc) template
/* variation on https://medium.com/@DanHomola/react-higher-order-components-in-typescript-made-simple-6f9b55691af1 */
import * as React from 'react'
import { wrapDisplayName } from 'recompose'
// Props you want the resulting component to take (besides the props of the wrapped component)
interface ExternalProps {}
// Props the HOC adds to the wrapped component
export interface InjectedProps {}
@dzjack
dzjack / eventEmitterMiddleware.js
Created April 14, 2018 11:40 — forked from ali/eventEmitterMiddleware.js
EventEmitterMiddleware allows your Redux actions to emit events to an external event emitter
/**
* A Redux middleware that externally emits events from actions.
* @param {EventEmitter} emitter - emits events
* @returns {Function} a Redux middleware
*/
export const eventEmitterMiddleware = (emitter) => {
if (!emitter) {
throw new Error('Cannot emit events. No EventEmitter provided.')
}
@dzjack
dzjack / haproxy.cfg
Created February 27, 2018 12:26 — forked from thisismitch/haproxy.cfg
Let's Encrypt Auto-Renewal script for HAProxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
@dzjack
dzjack / vyos.sh
Created February 14, 2018 07:02 — forked from jbrodriguez/vyos.sh
#!/bin/vbash
# CONFIG
wan=dhcp
lan=192.168.1.1
lan_segment=192.168.1.0
vpn_segment=192.168.5.0
domain=apertoire.org
lease_start=192.168.1.200
lease_stop=192.168.1.245