Skip to content

Instantly share code, notes, and snippets.

View grantglidewell's full-sized avatar

Grant Glidewell grantglidewell

View GitHub Profile
@grantglidewell
grantglidewell / index.html
Last active July 25, 2020 21:40
Printing
<!DOCTYPE html>
<html lang="en">
<head>
<script src="index.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>fingerprinting</title>
</head>
<body>
<div id="print-id-here">check the console, something went wrong :/</div>
defaults write com.apple.dock autohide-delay -float 0; killall Dock
defaults write com.apple.dock autohide-time-modifier -float 0.12;killall Dock
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useRef, useCallback, useEffect } from 'react';
export default function useDebouncedCallback<T extends (...args: any[]) => any>(
callback: T,
delay: number,
options: { maxWait?: number; leading?: boolean; trailing?: boolean } = {},
): [T, () => void, () => void] {
const maxWait = options.maxWait;
const maxWaitHandler = useRef<NodeJS.Timeout | null>(null);
function initObservable() {
let observableData = [];
let observers = [];
const updateData = newData => {
observableData = newData;
updateObservers()
};
const subscribe = obs => observers.push(obs);
const unsubscribe = f => (observers = observers.filter(obs => obs !== f));
find ./ -name "node_modules" -type d -prune -exec rm -rf '{}' +
@grantglidewell
grantglidewell / NotificationContext.js
Last active March 6, 2020 17:18
React Notification System (toaster)
import React, { createContext, useState, useContext } from 'react';
import PropTypes from 'prop-types';
import { Notification } from '../components';
const NotificationContext = createContext({});
const NotificationProvider = ({ children }) => {
const [notifications, updateNotifications] = useState([]);
/**
import { useEffect, useRef } from 'react'
function useTimeout(callback, delay) {
const savedCallback = useRef()
// Remember the latest callback.
useEffect(
() => {
savedCallback.current = callback
},
[callback]
)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.16862741112709045</real>
const fetch = require("node-fetch");
const WEBHOOK_URL = "WEBHOOK_FROM_NETLIFY";
const authUsers = ["USER_ID_FROM_SLACK"];
module.exports = async (req, res) => {
const { body } = req;
if (authUsers.includes(body.user_id)) {
// send the webhook
const Checkbox = styled.div`
width: 36px;
height: 36px;
border-radius: 6px;
transition: all 150ms;
border: ${colors.darkgrayFaded} solid 1px;
display: flex;
align-items: center;
cursor: pointer;
justify-content: center;