Skip to content

Instantly share code, notes, and snippets.

View TaniaAlex's full-sized avatar

TaniaAlex TaniaAlex

View GitHub Profile
@TaniaAlex
TaniaAlex / util.js
Created June 16, 2022 18:28 — forked from gitdagray/util.js
Javascript Utility Functions
// Youtube tutorial here: https://youtu.be/LDgPTw6tePk
// These functions are designed to be exported, but you could create a class instead. See tutorial video.
// #1 proper case
export const properCase = (string) => {
return `${string[0].toUpperCase()}${string.slice(1).toLowerCase()}`;
};
@TaniaAlex
TaniaAlex / machine.js
Last active April 9, 2021 11:30
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'loadFile',
initial: 'idle',
context: {
file: null,
loadedDataBlobUrl: '',
zipFileName: null,
loadedData: { inputData: null, productsOptions: {} },
error: null,
},
@TaniaAlex
TaniaAlex / splitPath.js
Created March 2, 2021 18:21 — forked from nopjia/splitPath.js
The ultimate split path, with a single regex
/**
* The ultimate split path.
* Extracts dirname, filename, extension, and trailing URL params.
* Correct handles:
* empty dirname,
* empty extension,
* random input (extracts as filename),
* multiple extensions (only extracts the last one),
* dotfiles (however, will extract extension if there is one)
* @param {string} path
@TaniaAlex
TaniaAlex / ImageUploadComponent.jsx
Created January 13, 2021 11:03 — forked from hartzis/ImageUploadComponent.jsx
React Image Upload with Preview
// https://codepen.io/hartzis/pen/VvNGZP
class ImageUpload extends Component {
constructor(props) {
super(props);
this.state = {
file: '',
imagePreviewUrl: ''
};
this._handleImageChange = this._handleImageChange.bind(this);
this._handleSubmit = this._handleSubmit.bind(this);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS Pseudo-class vs Pseudo-elements</title>
<meta name="viewport" content="width=device-width"/>
<style>
p{
color: cornflowerblue
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS border-radius</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="main.css">
<style>
body{
background-color: #ddd;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Combining position relative and absolute</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="main.css"/>
<style>
#main{
background-color: hsl(120, 30%, 80%);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS position: sticky</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="main.css"/>
<style>
dl{
margin: 1rem;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Intro to CSS Float</title>
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" href="main.css"/>
<style>
.one img{
float:left;

Project root:

yarn add -D --save-exact eslint-config-airbnb eslint-config-airbnb-typescript eslint-config-prettier eslint-config-react-app eslint-import-resolver-typescript eslint-webpack-plugin eslint-plugin-flowtype eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-react eslint-plugin-react-hooks babel-eslint eslint-plugin-jest @typescript-eslint/parser @typescript-eslint/eslint-plugin prettier prettier-eslint prettier-eslint-cli eslint-plugin-prettier

$ vim .eslintrc

{
  "plugins": ["prettier", "@typescript-eslint"],