One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
| import React, { useCallback, useState, useEffect, useContext, createContext } from 'react' | |
| const authContext = createContext() | |
| // Hook for child components to get the auth object and re-render when it changes. | |
| export default () => { | |
| return useContext(authContext) | |
| } | |
| // Provider component that wraps components and makes useAuth() available |
| const useStorage = (key, initialValue, storage) => { | |
| // Pass initial state function to useState so logic is only executed once | |
| const [storedValue, setStoredValue] = useState(() => { | |
| try { | |
| const item = storage.getItem(key) | |
| return item ? JSON.parse(item) : initialValue | |
| } catch (error) { | |
| console.error(error) | |
| return initialValue | |
| } |
| import { useEffect, useState, useCallback, useRef } from 'react' | |
| export default (asyncFunction, immediate = true) => { | |
| const [loading, setLoading] = useState(false) | |
| const [result, setResult] = useState(null) | |
| const [error, setError] = useState(null) | |
| // Track a reference to whether the useAsync is actually on a mounted component. | |
| // useEffect below returns a cleanup that sets this to false. Before setting | |
| // any state, we check if the cleanup has run. If it has, don't update the state. |
| let regex; | |
| /* matching a specific string */ | |
| regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello" | |
| regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO" | |
| regex = /hello/g; // looks for multiple occurrences of string between the forward slashes... | |
| /* wildcards */ | |
| regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo" | |
| regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo" |
| # Option 1 | |
| netstat -tulpn | grep 9090 | |
| # Option 2 | |
| sudo lsof -i -P -n | grep 9090 | |
| # Option | |
| sudo nmap -sT -O localhost |
| const { User } = require("src/db"); | |
| /** | |
| * Find all duplicates emails in the User | |
| * mongoose model (mapping users collection) | |
| * | |
| * | |
| * This aggregation function will groups the | |
| * documents comparing emaiils, sanitized | |
| * to lowercase; it adds the "_id" fields to |
| (function () { | |
| 'use strict'; | |
| angular.module('some.module') | |
| .controller('LoginController', loginController); | |
| /** @ngInject */ | |
| function loginController(localStorageService, AuthService) { | |
| ... |
| /** | |
| * Simple localStorage with Cookie Fallback | |
| * v.1.0.0 | |
| * | |
| * USAGE: | |
| * ---------------------------------------- | |
| * Set New / Modify: | |
| * store('my_key', 'some_value'); | |
| * | |
| * Retrieve: |
| { | |
| "name": "testing-hapi-js-apis", | |
| "version": "1.0.0", | |
| "license": "MIT", | |
| "scripts": { | |
| "test": "ava --verbose test.js" | |
| }, | |
| "dependencies": { | |
| "ava": "^0.16.0", | |
| "hapi": "^15.1.1" |