All are adopted from 8 Awesome React Hooks by Simon Holdorf
Found this link as well and have added some here ReactJS Hooks
| import React from "react"; | |
| function someResponsiveComponent() { | |
| const {height,width} = windowResizeEventListener(); | |
| return ( | |
| <p> | |
| The window <span>height = {height}</span><span>width = {width}</span> | |
| </p> | |
| ); | |
| } |
All are adopted from 8 Awesome React Hooks by Simon Holdorf
Found this link as well and have added some here ReactJS Hooks
| #!/usr/local/bin/node | |
| #!/usr/bin/env node | |
| const add = ( first, second ) => { | |
| return parseInt( first ) + parseInt( second ); | |
| } | |
| /** | |
| allows the javascript to be executed like this | |
| [14:08:27]/tmp $ ./add.js 1 2 |
| const {prefix} = require('../config.json'); | |
| /** | |
| * Usage string template. | |
| */ | |
| const usage = '<artifact quantity> <artifact level> <mention buyer>'; | |
| /** | |
| * The Agree Message | |
| * @param {string} seller - the Seller's name |
| from discord.utils import get | |
| @client.command(pass_context=True) | |
| async def giverole(ctx, member: discord.Member, *, role: discord.Role): | |
| check_role = get(ctx.message.server.roles, name='Board of Executives') | |
| if check_role not in member.roles: | |
| await client.say(f"You don't have the role '{str(role)}'") | |
| else: | |
| await client.add_roles(member, role) | |
| await client.say(f"The role '{str(role)}' has been given to {member.mention}.") |
| const not = val => !val; | |
| // How to parameterize describe in jest | |
| describe("index", () => { | |
| describe.each([ | |
| ['boolean', true, false], | |
| ['boolean', false, true], | |
| ['number', 0, true], | |
| ['number', 1, false], | |
| ['number', 999, false], | |
| ['number', -1, false], |
| const warnConsole = jest.spyOn(console, "warn").mockImplementation(() => {}); | |
| const errorConsole = jest.spyOn(console, "error").mockImplementation(() => {}); | |
| const infoConsole = jest.spyOn(console, "info").mockImplementation(() => {}); | |
| expect(warnConsole).toBeCalledWith('...'); | |
| expect(errorConsole).toBeCalledWith('...'); | |
| expect(infoConsole).toBeCalledWith('...'); | |
| expect(warnConsole).not.toHaveBeenCalled(); | |
| expect(errorConsole).not.toHaveBeenCalled(); |
| /** | |
| * mask values from an object (inverse of pluck). | |
| * @param {Object} [obj={}] - an Object, null and undefined return an empty obj literal. | |
| * @param {[String]} [keys=[]] - an array of keys to mask/remove from the object. | |
| * @return {Object} | |
| */ | |
| const mask = (obj = {}, keys = []) => Object.keys(obj).reduce((ac, key) => { | |
| ac[key] = (keys.some((p)=>(p===key))) ? void 0 : obj[key]; | |
| return ac; | |
| }, {}); |
ERR_TLS_CERT_ALTNAME_INVALID indicates self signed TLS error.
Obsured by the following where xxxx.xxx.com can be a variety of host names.
Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:xxxx.xxx.com\",\"cause\":{\"reason\":\"Host: localhost. is not in the cert's altnames: DNS:xxxx.xxx.com,