Skip to content

Instantly share code, notes, and snippets.

@thurt
thurt / gist:88df0e404b38b8923355ad0b9a700cff
Created April 5, 2018 15:16 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@thurt
thurt / build.sh
Created May 6, 2018 23:43 — forked from bobbytables/build.sh
Protocol Buffer build script for multiple folders
#!/usr/bin/env bash
# This script is meant to build and compile every protocolbuffer for each
# service declared in this repository (as defined by sub-directories).
# It compiles using docker containers based on Namely's protoc image
# seen here: https://github.com/namely/docker-protoc
set -e
REPOPATH=${REPOPATH-/opt/protolangs}
CURRENT_BRANCH=${CIRCLE_BRANCH-"branch-not-available"}

Enable Docker Remote API with TLS client verification

Docker's Remote API can be secured via TLS and client certificate verification.
First of all you need a few certificates and keys:

  • CA certificate
  • Server certificate
  • Server key
  • Client certificate
  • Client key

Create certificate files

function zipObject(keys, values) {
// often simple edge cases are taken care of at the top so they aren't hidden inside the middle of the function
if (keys === undefined && values === undefined) {
return {}; // for test 3
}
// category of problem: convert [] -> {}
// simple strategy for conversion problems is to create a blank object at the beginning, build it up in the middle, return it at the end
// create blank starter obj
@thurt
thurt / gitlab-ci.yml
Created February 20, 2019 04:46
Publish your create-react-app website via Gitlab CI. tags: #gitlab #git #deploy #ci
image: node:6.5.0 # can be upgraded, depending on your node version used
pages:
stage: deploy
script:
- npm install
- npm run build
- rm -rf public
- mv build public
artifacts:
import React, { Component } from "react";
import "./index.css";
import todosList from "./todos.json";
class App extends Component {
state = {
todos: todosList
};
handleCreateTodo = event => {
#!/bin/bash
# Verify Ruby is installed (Installed by default in MacOS)
if [ -x !"$(command -v ruby)" ]; then
echo 'Ruby is not installed. See instructor.'
exit 1
fi
# Install Homebrew
if [ ! -x "$(command -v brew)" ]; then
@thurt
thurt / Include-in-Sequelize.md
Created May 15, 2019 20:49 — forked from zcaceres/Include-in-Sequelize.md
using Include in sequelize

'Include' in Sequelize: The One Confusing Query That You Should Memorize

When querying your database in Sequelize, you'll often want data associated with a particular model which isn't in the model's table directly. This data is usually typically associated through join tables (e.g. a 'hasMany' or 'belongsToMany' association), or a foreign key (e.g. a 'hasOne' or 'belongsTo' association).

When you query, you'll receive just the rows you've looked for. With eager loading, you'll also get any associated data. For some reason, I can never remember the proper way to do eager loading when writing my Sequelize queries. I've seen others struggle with the same thing.

Eager loading is confusing because the 'include' that is uses has unfamiliar fields is set in an array rather than just an object.

So let's go through the one query that's worth memorizing to handle your eager loading.

The Basic Query

@thurt
thurt / specification.yaml
Created January 16, 2020 19:54
photo sharing specification file
openapi: 3.0.1
info:
title: Photo Sharing Service
version: "1.0.0"
servers:
- url: http://localhost:3000/api
description: localhost
- url: https://{domain}/api
description: Production Server
variables:
@thurt
thurt / ExampleQueryParam.js
Created April 2, 2020 18:36
Manually getting and setting query parameter in a component
import React, { useEffect, useState } from "react";
import { useHistory, useLocation } from "react-router";
const ExampleQueryParam = () => {
const history = useHistory();
const location = useLocation();
const [q, setQ] = useState(new URLSearchParams(location.search).get("q"));
useEffect(() => {
history.replace("?" + new URLSearchParams([["q", q]]).toString());