Skip to content

Instantly share code, notes, and snippets.

View dmdinh22's full-sized avatar
:octocat:
Always be coding

David Dinh dmdinh22

:octocat:
Always be coding
View GitHub Profile
@dmdinh22
dmdinh22 / better-nodejs-require-paths.md
Created September 24, 2018 04:49 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

const Article = require('../../../../app/models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@dmdinh22
dmdinh22 / ReduxMicroBoilerplate.js
Created September 24, 2018 04:49 — forked from gaearon/ReduxMicroBoilerplate.js
Super minimal React + Redux app
import React, { Component } from 'react';
import { createStore, combineReducers, applyMiddleware, bindActionCreators } from 'redux';
import { provide, connect } from 'react-redux';
import thunk from 'redux-thunk';
const AVAILABLE_SUBREDDITS = ['apple', 'pics'];
// ------------
// reducers
// ------------
@dmdinh22
dmdinh22 / react-reusable-component.md
Created September 24, 2018 04:49 — forked from ericelliott/react-reusable-component.md
React - Complete Reusable Component

React Reusable Component Factory

'use strict';

const ENTER_KEY = 13;

const emailFactory = function ({
  React,
  setEmail,
var str = 'class ΰ² _ΰ²  extends Array {constructor(j = "a", ...c) {const q = (({u: e}) => {return { [`s${c}`]: Symbol(j) };})({});super(j, q, ...c);}}' +
'new Promise((f) => {const a = function* (){return "\u{20BB7}".match(/./u)[0].length === 2 || true;};for (let vre of a()) {' +
'const [uw, as, he, re] = [new Set(), new WeakSet(), new Map(), new WeakMap()];break;}f(new Proxy({}, {get: (han, h) => h in han ? han[h] ' +
': "42".repeat(0o10)}));}).then(bi => new ΰ² _ΰ² (bi.rd));';
try {
eval(str);
} catch(e) {
alert('Your browser does not support ES6!')
}
@dmdinh22
dmdinh22 / react-event-handler-papp-props.jsx
Created September 24, 2018 04:48 — forked from sergiodxa/react-event-handler-papp-props.jsx
Example of how to use partial application to pass parameters to event handlers in React
// with props
import React, { Component } from 'react';
// this method work as a our base `handleClick` function
function handleClick(name, event) {
alert(`hello ${name}`);
}
class App extends Component {
constructor(props) {
@dmdinh22
dmdinh22 / react-lifecycle-cheatsheet.md
Created September 24, 2018 04:48 — forked from bvaughn/react-lifecycle-cheatsheet.md
React lifecycle cheatsheet

React lifecycle cheatsheet

Method Side effects1 State updates2 Example uses
Mounting
componentWillMount βœ“ Constructor equivalent for createClass
render Create and return element(s)
componentDidMount βœ“ βœ“ DOM manipulations, network requests, etc.
Updating
componentWillReceiveProps βœ“ Update state based on changed props
@dmdinh22
dmdinh22 / redux-is-smarter-than-you-think.md
Created September 24, 2018 04:48 — forked from armw4/redux-is-smarter-than-you-think.md
Optimizing your react components via redux....shouldComponentUpdate for free and more...

The Beginning

Yes...it's true...redux is smart....smarter than you even know. It really does want to help you. It strives to be sane and easy to reason about. With that being said, redux gives you optimizations for free that you probably were completely unaware of.

connect()

connect is the most important thing in redux land IMO. This is where you tie the not between redux and your underlying components. You usually take state and propogate it down your component hiearchy in the form of props. From there, presentational

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

@dmdinh22
dmdinh22 / System Design.md
Created September 24, 2018 04:42 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
@dmdinh22
dmdinh22 / ssh.md
Created August 6, 2018 06:51 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh [email protected]

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test