This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# The below code is an attemt to understand Elliptic Curve Cryptography | |
# by implementing Elliptic Curve Diffie-Hellman key exchange from scratch. | |
# DON'T USE THIS CODE IN YOUR APP!! | |
# It is not safe and is intended only as a learning tool. | |
import secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react" | |
import { useInstagramFeed } from "../useInstagramFeed" | |
const InstagramGallery = () => { | |
let photos = useInstagramFeed({ | |
userId: "3468531814", | |
thumbnailWidth: 640, | |
photoCount: 12, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Takes a callback and a delay, and deals with clearing timeouts as the callback value changes */ | |
export const useTimeout = (callback: () => void, delay: number | null) => { | |
// Hook found in this SO post | |
// https://stackoverflow.com/questions/53090432/react-hooks-right-way-to-clear-timeouts-and-intervals/53090848 | |
const timeoutRef = useRef<number>(0); | |
const callbackRef = useRef<() => void>(callback); | |
// Remember the latest callback: | |
// Without this, if you change the callback, when setTimeout kicks in, it | |
// will still call your old callback. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Takes a media query and returns a boolean value for whether or not specified media query was hit. | |
* -- e.g. '(min-width: 567px)' | |
*/ | |
export const useMediaQuery = (query: string): boolean => { | |
const mediaMatch: MediaQueryList = window.matchMedia(query); | |
const [matches, setMatches] = useState<boolean>(mediaMatch.matches); | |
useEffect(() => { | |
const handler = e => setMatches(e.matches); | |
mediaMatch.addEventListener('change', handler); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios, { AxiosError, AxiosResponse } from 'axios'; | |
import token from './somewhere'; | |
interface Todo { | |
id: string; | |
title: string; | |
} | |
interface User { | |
id: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (user, context, callback) { | |
if (context.clientMetadata && context.clientMetadata.shopify_domain && context.clientMetadata.shopify_multipass_secret) | |
{ | |
const RULE_NAME = 'shopify-multipasstoken'; | |
const CLIENTNAME = context.clientName; | |
console.log(`${RULE_NAME} started by ${CLIENTNAME}`); | |
const now = (new Date()).toISOString(); | |
let shopifyToken = { | |
email: user.email, |