Skip to content

Instantly share code, notes, and snippets.

View dbergey's full-sized avatar
🙃

Diana Bergey dbergey

🙃
View GitHub Profile
@jhackett1
jhackett1 / authContext.js
Created December 14, 2020 11:35
A React context showing how you might manage authentication
import React, { createContext, useContext } from "react"
import useSWR from "swr"
const AuthContext = createContext(false)
export const AuthProvider = (props) => {
const { data, error, mutate } = useSWR(`/api/v1/auth/me`)
const googleLogIn = async googleData => {
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@koop
koop / ensure-cert-macos.sh
Created November 28, 2017 20:27
Ensures a certificate is in the macOS system keychain.
#!/bin/bash
# Usage
# $ ./install-cert-macos.sh "/path/to/cert"
CERT_PATH="$1"
# First, grab the SHA-1 from the provided SSL cert.
CERT_SHA1=$(openssl x509 -in "$CERT_PATH" -sha1 -noout -fingerprint | cut -d "=" -f2 | sed "s/://g")
# Next, grab the SHA-1s of any standard.dev certs in the keychain.
# Don't return an error code if nothing is found.
@matthewjberger
matthewjberger / notes.md
Last active March 11, 2024 10:21
How to make an electron app using Create-React-App and Electron with Electron-Builder.
var obj = {
konamiCodeActive: false,
konamiCodeListener: function() {
if ( window.addEventListener ) {
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
window.addEventListener("keydown", function(e){
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 && !obj.konamiCodeActive) {
obj.konamiCodeActive = true;
@dtrenz
dtrenz / copy-rest-api-postman.json
Created November 5, 2013 15:08
Copy REST API Postman Collection
{
"id": "c64a107a-39ab-27b4-9c37-d93b1e187589",
"name": "Copy API (REST)",
"description": "## API Calls\n\nThis is the meat and potatoes of this document. Here we'll discuss the various API calls you can make to our servers, along with what inputs we require, and what outputs you can expect back, and the required permissions to perform the request. Since this is a RESTful JSON API, you will need to know the URLs ahead of time.\n\nIn the URLs of the sample requests, words that appear in all CAPITAL letters represent the part of the URL which is meant to be changed by you, the developer, depending on the intention of your request.\n\n##### Request Headers\n\nYou will need to provide the following two HTTP request headers while talking to the Copy API:\n\n* **X-Api-Version**: 1\n* **Accept**: application/json\n\n##### Response Headers\n\nHere's a list of some typical response headers to expect from our server, most of which can be ignored.\n\n* **Access-Control-Allow-Headers**: X-AUTHORIZATION-ANON,
@CAFxX
CAFxX / cache.phpi
Created December 18, 2011 16:58
PHP remote file/URL cache
<?php
/*
A simple cache for remote files/URLs
2011 Carlo Alberto Ferraris <cafxx@strayorange.com>
===================================================
The cache function allows you to get the contents of a remote URL at
most once every N seconds. It also supports the If-Modified-Since HTTP
header to avoid fetching the resource again if it hasn't changed.