Skip to content

Instantly share code, notes, and snippets.

@0bie
0bie / ES6Notes.md
Last active November 2, 2016 19:10
ES6 Notes
@0bie
0bie / ClassPrototypeES5.md
Last active July 22, 2016 18:00
Class/Protoype in ES5

Boilerplate structure for working w/ classes in ES5

function Module(variable1, variable2) {
    this.variable1 = variable1;
    this.variable2 = variable2;
}
Module.prototype = {
   constructor: Module, // specifies the constructor for new instances of the Module class
   currentScope: function() {console.log(this);},
@0bie
0bie / ModulePatternES5.md
Created May 15, 2016 01:29
Module Pattern in ES5
  • It is considered best practice to manage scope using the Module Pattern
  • It enables access to both a public and private scope in your code
  • In basic terms you may get this done by wrapping a function inside a function like so:
var Module = (function() {
  var _privateMethod1 = function() {
    console.log("private 1");  
  };
 var _privateMethod2 = function() {
@0bie
0bie / zIndex.md
Last active May 28, 2016 23:23
Guideline: Z-Index Scale

Guideline: Z-Index Scale

  • The default scale is a set of variables numbered from 1 - 9 E.g:
/* Base z-index scale */

:root {
  --zIndex-1: 10;
 --zIndex-2: 20;
@0bie
0bie / ReactNotes.md
Last active February 23, 2024 23:32
Beginner Notes on React JS

React Notes

JSX

  • JSX adds XML syntax to JS

  • JSX tags have a tag name, attributes, and children (similar to XML)

  • Similar to JS, quotes in JSX attributes represent strings. Numeric values and/or expressions should be wrapped in a curly brace.

@0bie
0bie / ReactNotes2.md
Last active June 21, 2018 09:57
Beginner notes on React JS

React Notes 2

  • To prevent syntax repetition you can abstract common properties from the React object using ES6 Destructuring E.g:
//before
import React from 'react';

class Searchbar extends React.Component {
 static propTypes = {
@0bie
0bie / decorators.md
Last active September 21, 2022 18:00
Working with decorators in React
  • An ES2016 decorator is an expression which returns a function and can take a target, name and property descriptor as arguments.
  • A decorator takes an argument (the function being decorated) and returns the same function with added functionality.
  • Decorators are helpful for anything you want to transparently wrap with extra functionality.
  • Its simplest form (React):
const HOC = (Component) => (props) => <Component {...props} />;
@0bie
0bie / functionalSnippets.js
Last active September 21, 2022 10:56
functional js snippets
const overlay = (element) => {
const newElement = document.createElement(element);
newElement.style.height = '100vh';
return newElement;
};
const onEvent = (inputType, DOMElement, callback) => {
if (DOMElement.addEventListener){
DOMElement.addEventListener(inputType, callback);
}
@0bie
0bie / npm.md
Last active September 21, 2022 17:54
npm beginner notes

npm commands

  • Update npm: npm install npm --global || npm i npm -g
  • New package: npm init --yes || npm init -y
  • Scopes: npm init --scope=myusername npm install @myusername/mypackage require('@myusername/mypackage')
  • Add dependencies: npm install --save package-name || npm i -s package-name
  • Add devDependencies: npm install --save-dev package-name || npm i -D package-name
  • Skip devDependencies: npm install --production
  • Add bundled dependencies: npm install --save --save-bundle package-name
  • Update dependencies: npm outdated &amp;&amp; npm update