Skip to content

Instantly share code, notes, and snippets.

@gadflying
gadflying / schema.md
Created March 26, 2021 22:19
[schema]
{
  "name": "George Washington",
  "birthday": "February 22, 1732",
  "address": "Mount Vernon, Virginia, United States"
}

{
  "first_name": "George",
 "last_name": "Washington",
@gadflying
gadflying / uuid-generator.js
Last active February 18, 2021 07:57
[uuid-generator]
sd
@gadflying
gadflying / arg.md
Last active January 8, 2021 21:38
[How to parse command line arguments] #nodejs #yargs

Passing in arguments via the command line

all command-line arguments received by the shell are given to the process in an array called argv

console.log(process.argv);

Now save it, and try the following in your shell:

$ node argv.js one two three four five
@gadflying
gadflying / New_TypeScript_Project.md
Last active January 8, 2021 00:16
[How To Set Up a New TypeScript Project] #typescript

Step 1 — Starting the TypeScript Project

To begin your TypeScript project, you will need to create a directory for your project:

mkdir typescript-project

Now change into your project directory:

@gadflying
gadflying / JestMocks.md
Last active July 31, 2023 05:01
[Understanding Jest Mocks] #jest

When we talk about mocking in Jest, we’re typically talking about

replacing dependencies with the Mock Function.

review the Mock Function, and then dive into the different ways you can replace dependencies with it. The Mock Function The goal for mocking is to replace something we don’t control with something we do,

@gadflying
gadflying / mockImportedFunction.md
Last active June 25, 2024 10:37
[How to mock imported named function in Jest when module is unmocked] #jest #reactTestLib
// myModule.test.js

jest.mock('./myModule.js', () => (
  {
    ...(jest.requireActual('./myModule.js')),
    otherFn: jest.fn()
  }
))
@gadflying
gadflying / Dockerizing.md
Created January 5, 2021 19:37
[Dockerizing a Node.js Web Application] #docker

Dockerizing a Node.js Web Application

https://semaphoreci.com/community/tutorials/dockerizing-a-node-js-web-application

What is Docker, Anyway?

“Docker is an open platform for building, shipping and running distributed applications. It gives programmers, development teams and operations engineers the common toolbox they need to take advantage of the distributed and networked nature of modern applications.”

is an abstraction on top of low-level operating system tools that allows you to run one or more containerized processes or applications within one or more virtualized Linux instances.

@gadflying
gadflying / yarnBasic.md
Created January 4, 2021 19:09
[yarn] #yarn

Starting a new project

yarn init Adding a dependency

yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]
@gadflying
gadflying / debug.md
Last active January 5, 2021 07:09
[debug] #reactTestLib
   const { container, getByDisplayValue, getByTestId, debug } =  renderWithProviders(
            <FieldComponentRenderer  {...props} enableError={true}/>
        );

debug()
@gadflying
gadflying / FocusManager.jsx
Created August 19, 2019 23:09 — forked from forgo/FocusManager.jsx
Handle composite focus and blur events in React.
import React from 'react'
import ReactDOM from 'react-dom'
import { Key } from '../utils/keyboardUtils'
export default class FocusManager extends React.Component {
constructor(props) {
super(props)
this._immediateID = null
this.state = {