Python syntax here : 2.7 - online REPL
Javascript ES6 via Babel transpilation - online REPL
import math
function OnBlurComponent({ onBlur }) { | |
const handleBlur = (e) => { | |
const currentTarget = e.currentTarget; | |
// Check the newly focused element in the next tick of the event loop | |
setTimeout(() => { | |
// Check if the new activeElement is a child of the original container | |
if (!currentTarget.contains(document.activeElement)) { | |
// You can invoke a callback or add custom logic here | |
onBlur(); |
#!/usr/bin/env bash | |
# | |
# Bootstrap script for setting up a new OSX machine | |
# | |
# This should be idempotent so it can be run multiple times. | |
# | |
# Some apps don't have a cask and so still need to be installed by hand. These | |
# include: | |
# | |
# - Twitter (app store) |
from pprint import pformat | |
from typing import Any | |
from pygments import highlight | |
from pygments.formatters import Terminal256Formatter | |
from pygments.lexers import PythonLexer | |
def pprint_color(obj: Any) -> None: | |
"""Pretty-print in color.""" |
Python syntax here : 2.7 - online REPL
Javascript ES6 via Babel transpilation - online REPL
import math
Given an encoded (base64
) JWT (access_token
).
For example, see this sample OAuth2 response generated by JBoss APIMan/Keycloak
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/json
Date: Tue, 25 Aug 2015 19:25:12 GMT
// Babel 2015 - ES6 | |
// Convert a complex JS Object to GraphQL Query, should handle most use cases as of 21/01/2016 | |
const o = { | |
query: { | |
fields: { | |
complex: { | |
aliasFor: "Products", | |
processArgs: { | |
coupon: (value) => { | |
return `"${JSON.stringify(value).replace(/"/g, "\\\"")}"`; // passing json string as a argument |
Credit to answer found here http://stackoverflow.com/questions/21095054/ssh-key-still-asking-for-password-and-passphrase
This will ask you for the passphrase, enter it and it won't ask again.
ssh-add ~/.ssh/id_rsa &>/dev/null
import { useLayoutEffect, useCallback, useState } from 'react' | |
export const useRect = (ref) => { | |
const [rect, setRect] = useState(getRect(ref ? ref.current : null)) | |
const handleResize = useCallback(() => { | |
if (!ref.current) { | |
return | |
} |
#!/usr/bin/env bash | |
# | |
# BUGS: | |
# 1. not adding settings to .zshrc from below (i.e. default theme, packages, custom functions, etc.) | |
# 2. not auto-hiding doc | |
# 3. not auto-hiding menu bar | |
# 4. not adding .vimrc | |
# 5. not automatically copying iTerm profile, Option + Space not setup to toggle iTerm, doesn't default to opening iTerm at startup | |
# | |
# Bootstrap script for setting up a new OSX machine |