Skip to content

Instantly share code, notes, and snippets.

@CoralSilver
CoralSilver / npm-version.md
Created March 11, 2020 19:26
Show all published npm versions (that aren't alpha or beta releases)

npm show webpack@* version

@CoralSilver
CoralSilver / debounce.js
Last active December 6, 2019 02:11
Debounce function implemented in ES6
// As long as it continues to be invoked, the callback will not be triggered.
// The function will be called after it stops being called for N milliseconds.
const debounce = (callback, wait) => {
// there is no timeout by default
let timeout = null
return function(...args) {
// last timeout is cleared every time after first call
clearTimeout(timeout)
// callback will only be fired if it was not cleared by invocation occuring before N milliseconds
@CoralSilver
CoralSilver / generateRandomRGB.js
Created November 17, 2019 00:36
function to randomly generate a color with a set opacity
// default shade value of 200, increment up to 255 for brighter colors, deincrement down to 0 for darker colors
const generateRandomRGB = (shade = 200, alpha = 1) => {
shade = (shade >= 0 && shade <= 255) ? shade : 255;
const generateRandomColor = () => {
return Math.ceil(Math.random() * shade);
}
const red = generateRandomColor(shade);
@CoralSilver
CoralSilver / gitflow.md
Created June 19, 2018 13:25 — forked from sheremetat/gitflow.md
Git rebase workflow

Step 1: Checkout a new working branch from updated master

 git checkout -b <branchname>

Step 2: Make Changes

 git add
 git commit -m "description of changes"

Step 3: Sync with remote

@CoralSilver
CoralSilver / removeKey.js
Last active May 13, 2018 18:08
Remove key from object with ES6 destructing
function removeByKey (myObj, deleteKey) {
return Object.keys(myObj)
.filter(key => key !== deleteKey)
.reduce((result, current) => {
result[current] = myObj[current];
return result;
}, {});
}
// Helper function
@CoralSilver
CoralSilver / README.md
Created May 1, 2018 21:08 — forked from mjfoster83/README.md
D3js v4 Stacked Bar Chart - with Tooltip Hover
@CoralSilver
CoralSilver / README.md
Created May 1, 2018 21:08 — forked from mjfoster83/README.md
D3js v4 Stacked Bar Chart - with Tooltip Hover
@CoralSilver
CoralSilver / Typography.md
Last active November 21, 2022 20:26
React Typography Component

Typography

The Typography component can be used to render most html text elements.

import Typography from 'react-toolbox/lib/typography';

const TypographyTest = () => (
 
@CoralSilver
CoralSilver / using-eslint-with-prettier.md
Created March 27, 2018 14:55 — forked from yangshun/using-eslint-with-prettier.md
Comparison between tools that allow you to use ESLint and Prettier together.
prettier-eslint eslint-plugin-prettier eslint-config-prettier
What it is A JavaScript module exporting a single function. An ESLint plugin. An ESLint configuration.
What it does Runs the code (string) through prettier then eslint --fix. The output is also a string. Plugins usually contain implementations for additional rules that ESLint will check for. This plugin uses Prettier under the hood and will raise ESLint errors when your code differs from Prettier's expected output. This config turns off formatting-related rules that might conflict with Prettier, allowing you to use Prettier with other ESLint configs like eslint-config-airbnb.
How to use it Either calling the function in your code or via [prettier-eslint-cli](https://github.co
@CoralSilver
CoralSilver / .editorconfig
Created February 23, 2018 04:15
Editor Config
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true