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 useCachedAbortiveQuery<T>( | |
query: DocumentNode, | |
variables: Record<string, unknown>, | |
deps: Array<any> | |
) { | |
const apolloClient = useApolloClient(); | |
const [data, setData] = useState<T>(); | |
const [error, setError] = useState<Error | null>(null); | |
const [loading, setLoading] = useState<boolean>(true); |
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 bash | |
set -Eeuo pipefail | |
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 | |
trap cleanup SIGINT SIGTERM ERR EXIT | |
usage() { | |
cat <<EOF |
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
if (!Array.prototype.flat) { | |
Object.defineProperty(Array.prototype, 'flat', { | |
configurable: true, | |
value: function flat () { | |
var depth = isNaN(arguments[0]) ? 1 : Number(arguments[0]); | |
return depth ? Array.prototype.reduce.call(this, function (acc, cur) { | |
if (Array.isArray(cur)) { | |
acc.push.apply(acc, flat.call(cur, depth - 1)); | |
} else { |
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
/** | |
* Please note this code is just a proof of concept and should not | |
* be used in production! | |
* | |
* Based on https://github.com/airbnb/babel-plugin-dynamic-import-node | |
*/ | |
import syntax from 'babel-plugin-syntax-dynamic-import'; | |
export default function ({ template, types: t }) { |
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
for (var i=0;i<document.styleSheets.length;i++) { | |
console.group(document.styleSheets[i].href); | |
for (var j=0;j<document.styleSheets[i].cssRules.length;j++) | |
{ | |
var rule =document.styleSheets[i].cssRules[j]; | |
if (rule instanceof CSSFontFaceRule) { | |
console.log(rule.cssText); | |
} | |
} | |
console.groupEnd(); |
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
/** | |
* Converts: | |
* From: <button onClick={someIdentifier && this.handleClick} /> | |
* To: <button onClick={someIdentifier ? this.handleClick : undefined} /> | |
*/ | |
export default function transformer(file, api) { | |
const j = api.jscodeshift; | |
const interactiveEventTypeNames = [ | |
'blur', |
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
/** | |
* @jest-environment jsdom | |
*/ | |
import React, { Component } from "react"; | |
import { mount } from "enzyme"; | |
const Updated = () => <div>Updated!</div>; | |
class TimeoutComponent extends Component { | |
state = { |
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
Secure sessions are easy, but it's not very well documented, so I'm changing that. | |
Here's a recipe for secure sessions in Node.js when NginX is used as an SSL proxy: | |
The desired configuration for using NginX as an SSL proxy is to offload SSL processing | |
and to put a hardened web server in front of your Node.js application, like: | |
[NODE.JS APP] <- HTTP -> [NginX] <- HTTPS -> [CLIENT] | |
To do this, here's what you need to do: |
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
#!/bin/bash | |
# Command line tools | |
# Install and accept xcode-select first!!! | |
# xcode-select --install | |
# Install Homebrew Dawg! | |
echo Installing brew | |
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
echo Installing essentials |
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
/** | |
* This is NOT DOM events (click, mouseover, touchend, etc...) | |
* This is custom events, which can be bound to anything. | |
*/ | |
var ee = function(){}; | |
//bind function to event | |
ee.prototype.on = function(key, fn){ | |
//if not function, bail | |
if(typeof fn !== 'function'){ return false; } |
NewerOlder