Skip to content

Instantly share code, notes, and snippets.

View cdock1029's full-sized avatar
🏠
Working from home

Conor Dockry cdock1029

🏠
Working from home
View GitHub Profile
@cdock1029
cdock1029 / package.json
Created July 19, 2018 18:48 — forked from stefanjudis/package.json
Cached SQIP implementation on Netlify
{
"name": "sqip-cache-tryout",
"version": "1.0.0",
"description": "",
"main": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "stefan judis <stefanjudis@gmail.com>",
@codyzu
codyzu / every-5-minutes.cron.yaml
Created February 27, 2018 16:53
Kubernetes CronJob publishing to a PubSub topic
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: every-5-minutes
spec:
schedule: "*/5 * * * *"
jobTemplate:
spec:
template:
spec:
@kerwynrg
kerwynrg / Root.jsx
Last active November 13, 2018 11:12
Workaround to work with create-react-app-typescript and react-hot-loader
import * as React from 'react';
import { hot } from 'react-hot-loader';
import { Provider } from 'react-redux';
import DevTools from '../Devtools';
import configureStore from '../../store/configureStore';
import App from '../App';
import ApplicationState from '../../store/store.types';
import { fetchAuth } from '../../store/common/Auth/Auth';
@kentcdodds
kentcdodds / use-deep-compare-effect.js
Created November 9, 2018 16:10
a custom react hook that I want feedback on because it feels like a lot of work and maybe I'm missing something...
// Feedback requested on the useDeepCompareEffect
// it just feels like a bit of work...
// HERE'S THE REASON I NEED THIS:
// when people use the useQuery hook, they'll typically
// do so like this: `useQuery(myQuery, {var1: props.value})`
// which means that passing `variables` to `useEffect` will
// trigger a rerun of the callback even if they didn't
// actually change (referrential equality)
function useQuery({query, variables}) {
@dustypomerleau
dustypomerleau / global.code-snippets
Created May 26, 2020 02:32
Library/Application\ Support/Code/User/snippets/global.code-snippets
{
"lv_module": {
"scope": "elixir, html-eex",
"prefix": "lv",
"body": [
"defmodule ${1}Web.${2}Live do",
" use ${1}Web, :live_view",
"end"
],
"description": "LiveView module"
import type { Action, Loader } from "@remix-run/loader";
import { json, parseFormBody, redirect } from "@remix-run/loader";
import { readTodos, createTodo, deleteTodo } from "../data/todo";
let action: Action = async ({ request, context: { session } }) => {
let [method, body] = await methodOverride(request);
await new Promise((res) => setTimeout(res, 1000));
switch (method) {
case "post": {
let [_, error] = await createTodo(body!.name);
@cesarandreu
cesarandreu / sensible-defaults.css
Created June 2, 2018 10:04
Sensible css defaults taken from css-layout
div, span {
box-sizing: border-box;
position: relative;
display: flex;
flex-direction: column;
align-items: stretch;
flex-shrink: 0;
align-content: flex-start;
@bvaughn
bvaughn / updating-subscriptions-when-props-change-example.js
Last active March 27, 2022 09:29
Advanced example for manually updating subscriptions in response to props changes in an async-safe way
// This is an advanced example! It is not typically required for application code.
// If you are using a library like Redux or MobX, use the container component provided by that library.
// If you are authoring such a library, use the technique shown below.
// This example shows how to safely update subscriptions in response to props changes.
// In this case, it is important to wait until `componentDidUpdate` before removing a subscription.
// In the event that a render is cancelled before being committed, this will prevent us from unsubscribing prematurely.
// We also need to be careful about how we handle events that are dispatched in between
// `getDerivedStateFromProps` and `componentDidUpdate` so that we don't put stale values into the `state`.
<!DOCTYPE html>
<meta charset="utf-8">
<title>Twitter Archive Viewer</title>
<script>window.YTD = { tweet: {} }</script>
<script src="tweet.js"></script><!-- this is loading a file from the archive -->
<style>
.tweet { border: 1px solid #eee; margin: 8px }
.full_text { padding: 8px }
.created_at { padding: 8px; color: #777 }
</style>
@laurenfazah
laurenfazah / authentication_with_express_postgres.md
Last active November 8, 2022 01:51
Authentication with an Express API and Postgres

Authentication with an Express API and Postgres

Setting Up

Let's make sure our Express app has the required base modules:

# within root of API
npm install --save express pg knex bcrypt
npm install --save-dev nodemon