Skip to content

Instantly share code, notes, and snippets.

export const getUniqueColorsForShowIds = (showIds: number[]) => {
console.log("colors.length "+colors.length);
console.log("showIds "+showIds);
// get list of indicies in color array
const listOfIndicies: number[] = showIds.map(id => {
// using modulus operator, so if id = 103 and color.length = 100, then colorIndex will be 3
const colorIndex = id % colors.length;
return colorIndex;
});
@carsenchan
carsenchan / setup.md
Last active May 30, 2022 05:30
Eslint + Prettier for React Typescript

Project setup

Purpose

To ensure that the coding style is consisitent in the project from different members, for React + Typescript projects, it is recommanded set up ESlint and Prettier.

  1. Install the required dev dependencies:
yarn add eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-react -D
@sidsbrmnn
sidsbrmnn / .babelrc
Last active August 13, 2023 18:11
Production-ready webpack configuration for React applications in Typescript
{
"presets": ["@babel/env", "@babel/react", "@babel/typescript"],
"plugins": [
"@babel/proposal-object-rest-spread",
["@babel/plugin-transform-runtime", { "regenerator": true }]
]
}
@ibraheem4
ibraheem4 / postgres-brew.md
Last active May 1, 2024 09:43 — forked from sgnl/postgres-brew.md
Installing Postgres via Brew (OSX)

Installing Postgres via Brew

Pre-Reqs

Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
@olssonm
olssonm / macos-disable-resize
Last active April 30, 2024 12:23
Disable resizing of the macOS dock
defaults write com.apple.dock size-immutable -bool true; killall Dock
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@afternoon
afternoon / rename_js_files.sh
Created February 15, 2014 18:04
Rename .js files to .ts
find app/src -name "*.js" -exec sh -c 'mv "$0" "${0%.js}.ts"' {} \;
@mucar
mucar / random_color_array.js
Created October 16, 2012 11:47
Javascript Random Color Array
var colorArray = ['#FF6633', '#FFB399', '#FF33FF', '#FFFF99', '#00B3E6',
'#E6B333', '#3366E6', '#999966', '#99FF99', '#B34D4D',
'#80B300', '#809900', '#E6B3B3', '#6680B3', '#66991A',
'#FF99E6', '#CCFF1A', '#FF1A66', '#E6331A', '#33FFCC',
'#66994D', '#B366CC', '#4D8000', '#B33300', '#CC80CC',
'#66664D', '#991AFF', '#E666FF', '#4DB3FF', '#1AB399',
'#E666B3', '#33991A', '#CC9999', '#B3B31A', '#00E680',
'#4D8066', '#809980', '#E6FF80', '#1AFF33', '#999933',
'#FF3380', '#CCCC00', '#66E64D', '#4D80CC', '#9900B3',
'#E64D66', '#4DB380', '#FF4D4D', '#99E6E6', '#6666FF'];