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 {css, CSSInterpolation} from "@emotion/css" | |
import { | |
Attributes, | |
ComponentClass, | |
createElement, | |
FC, | |
HTMLProps, | |
RefAttributes, | |
SVGProps, | |
} from "react" |
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
--[[ | |
Usage: Logitech G HUB > Menu > Games & Applications > Profiles > Default > Scripting | |
Bottom button click: mission control. | |
Bottom button press & swipe left / right: go desktop left / right. | |
Bottom button press & swipe up / down: more mac menus... | |
Top button press: allows scrolling of left and right directions. | |
--]] | |
btnA = 4; | |
btnB = 5; |
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 | |
# Usage: ./mongodb-json-export.sh dbName | |
DB=$1 | |
COLLECTIONS=$(mongo localhost:27017/$DB --quiet --eval "db.getCollectionNames()" | tr -d '\[\]\"[:space:]' | tr ',' ' ') | |
mkdir json | |
for collection in $COLLECTIONS; 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
import { | |
createElement as element, | |
createContext, | |
useContext, | |
FC, | |
ReactNode, | |
useState, | |
useMemo, | |
useEffect, | |
} from 'react' |
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
/** | |
* Mutation observer is not a big library. Rather it's a simple way to observe: | |
* 1. New attributes on nodes. | |
* 2. Added / removed node to document. | |
* 3. Changes to "contenteditable" text elements. | |
*/ | |
const observer = new MutationObserver((mutationsList, observer) => { | |
for (let mutation of mutationsList) { | |
if (mutation.type === 'attributes') { |
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 from 'axios'; | |
async function getGoogleUserInfo(access_token) { | |
const { data } = await axios({ | |
url: 'https://www.googleapis.com/oauth2/v2/userinfo', | |
method: 'get', | |
headers: { | |
Authorization: `Bearer ${access_token}`, | |
}, | |
}); |
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 from 'axios'; | |
async function getAccessTokenFromCode(code) { | |
const { data } = await axios({ | |
url: `https://oauth2.googleapis.com/token`, | |
method: 'post', | |
data: { | |
client_id: process.env.APP_ID_GOES_HERE, | |
client_secret: process.env.APP_SECRET_GOES_HERE, | |
redirect_uri: 'https://www.example.com/authenticate/google', |
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 * as queryString from 'query-string'; | |
const urlParams = queryString.parse(window.location.search); | |
if (urlParams.error) { | |
console.log(`An error occurred: ${urlParams.error}`); | |
} else { | |
console.log(`The code is: ${urlParams.code}`); | |
} |
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 * as queryString from 'query-string'; | |
const stringifiedParams = queryString.stringify({ | |
client_id: process.env.CLIENT_ID_GOES_HERE, | |
redirect_uri: 'https://www.example.com/authenticate/google', | |
scope: [ | |
'https://www.googleapis.com/auth/userinfo.email', | |
'https://www.googleapis.com/auth/userinfo.profile', | |
].join(' '), // space seperated string | |
response_type: 'code', |
NewerOlder