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
/* global React, ReactDOM, document, SubComponent */ | |
/* | |
eslint-disable | |
react/react-in-jsx-scope, | |
react/jsx-filename-extension, | |
react/jsx-one-expression-per-line, | |
no-useless-constructor, | |
react/prefer-stateless-function, | |
react/jsx-no-undef |
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
/** | |
* You can use require here | |
* @example | |
* const sub = require('./sub') | |
* console.log('SUB >>',sub.default()) | |
*/ | |
ReactDOM.render((<h1>It Works!</h1>), document.getElementById('root')); |
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
/* Some conponent which uses contextState and has be connected (subscribed) to the store data */ | |
const MyContextUser = props => { | |
// console.log('render', props.id) | |
return ( | |
<div> | |
<div>{ props.myContextState.count }</div> | |
{ props.title | |
&& ( | |
<button | |
onClick={() => props.myContextState.setState({ count: props.myContextState.count + 1 })} |
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
const exampleApi = { | |
async getMovies(){ | |
return fetch('https://jsonplaceholder.typicode.com/todos/1') | |
.then((response) => { | |
return response.json(); | |
}) | |
} | |
} | |
exampleApi.getMovies().then(console.log) |
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
#! /usr/bin/env bash | |
# kard, 20201020, https://gist.github.com/dkarmalita/c2bdec0181ca7dc81902138d004f34ad | |
# Run the caffeinate prefaced by date and time stamp. After the script | |
# finished (use "q" key), it cleans all of the caffeinate processes. | |
echo Caff starts at $(date "+%H:%M:%S %d/%m/%y") | |
caffeinate -di & | |
n="_" |
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
#! /usr/bin/env bash | |
# kard 20201020, https://gist.github.com/dkarmalita/25225177299bcf7f80584b8d13fc5a0c | |
# OSX, | |
# Run pins with date/time stamps in each line. It stores the log in the ping.log | |
# file within the current working directory and opens the Console application within | |
# the log opened. Also, it uses caffeinate to prevent the computer from fall to sleep. | |
# After the script finishing, all of the processes are automatically closed. | |
echo Ping logger starts at $(date "+%H:%M:%S %d/%m/%y") |
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
/** | |
@example | |
const { getNodeOptionValue } = require('nodeOptions'); | |
const maxOldSpaceSize = getNodeOptionValue('max_old_space_size'); | |
*/ | |
const parseNodeOptions = () => (!process.env.NODE_OPTIONS ? [] : process.env.NODE_OPTIONS.split(/[=:]/)); | |
const _optionsArr = parseNodeOptions(); | |
const _getOptionsCount = () => (_optionsArr.length ? _optionsArr.length / 2 : 0); | |
const _getOptionName = i => _optionsArr[i * 2]; |
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
// v20200514 + extendVal | |
/* eslint-disable no-restricted-syntax, guard-for-in, */ | |
module.exports = function cloneObject( | |
aObject, | |
extendVal = x => x, | |
) { | |
if ( | |
!aObject | |
|| (typeof aObject !== 'object') | |
) { |
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
const net = require('net'); | |
const isPortOpen = async (port, { timeout = 1000, host } = {}) => { | |
const promise = new Promise(((resolve, reject) => { | |
const socket = new net.Socket(); | |
const onError = () => { | |
socket.destroy(); | |
reject(); | |
}; |
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
export default function getSearchValueFromUrl(searchKey, removeFromUrl) { | |
const { origin, pathname, search, hash } = window.location; | |
const params = new URLSearchParams(search); | |
const value = params.get(searchKey); | |
if (removeFromUrl) { | |
params.delete(searchKey); | |
const nextsearch = params.toString(); | |
const newHref = `${origin}${pathname}${nextsearch ? `?${nextsearch}` : ''}${hash}`; | |
window.history.replaceState(null, '', newHref); | |
} |
NewerOlder