A simple way to detect a click outside of an element with vanilla JavaScript
A Pen by Marcelo Ribeiro on CodePen.
var readline = require('readline'); | |
readline.emitKeypressEvents(process.stdin); | |
if (process.stdin.isTTY) | |
process.stdin.setRawMode(true); | |
process.stdin.on('keypress', (chunk, key) => { | |
if (key && key.name == 'q') | |
process.exit(); |
import 'package:flutter/material.dart'; | |
import 'package:shared_preferences/shared_preferences.dart'; | |
//https://stackoverflow.com/a/53107519/10409567 | |
void main() async { | |
// load the shared preferences from disk before the app is started | |
WidgetsFlutterBinding.ensureInitialized(); | |
final prefs = await SharedPreferences.getInstance(); | |
// create new theme controller, which will get the currently selected from shared preferences |
A simple way to detect a click outside of an element with vanilla JavaScript
A Pen by Marcelo Ribeiro on CodePen.
Scenario: you have both OpenSSL 1.0 and 1.1 installed (using Brew) in your OSX system and you want to switch the current active version without removing other versions that already installed. Here is how to do it.
$ ls -al /usr/local/Cellar/openssl*
/usr/local/Cellar/openssl:
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
(() => { | |
const SHOW_SIDES = false; // color sides of DOM nodes? | |
const COLOR_SURFACE = true; // color tops of DOM nodes? | |
const COLOR_RANDOM = false; // randomise color? | |
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
const THICKNESS = 20; // thickness of layers | |
const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |