Skip to content

Instantly share code, notes, and snippets.

@nguyentu9
nguyentu9 / slim-redux.js
Created October 18, 2021 01:09 — forked from gaearon/slim-redux.js
Redux without the sanity checks in a single file. Don't use this, use normal Redux. :-)
function mapValues(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
result[key] = fn(obj[key], key);
return result;
}, {});
}
function pick(obj, fn) {
return Object.keys(obj).reduce((result, key) => {
if (fn(obj[key])) {
@nguyentu9
nguyentu9 / README.md
Created October 17, 2021 06:27 — forked from hofmannsven/README.md
SCSS Cheatsheet
import React, { useMemo, useState, useEffect } from "react";
import { render } from "react-dom";
function useAsync() {
return useMemo(() => {
let controller;
const start = (url, options, update) => {
// sử dụng AbortController để thông báo với fetch rằng chúng ta muốn cancel 1 request
controller = new AbortController();
const signal = controller.signal;

Async action là gì?

  • Async => bất đồng bộ?, Action => hành động?
  • là một action trong trạng thái chưa sẵn sàng thực thi ví dụ Fetch API request lên server

Tại sao cần Middleware khi sử dụng Async action?

  • React không hỗ trợ async action => cần 1 middleware trung gian điều phối việc nhận kết quả fetch trả về từ api rồi khi nào mới được dispatch => đảm bảo không bị lỗi chương trình react

Middleware là gì?

  • khác với middleware ở server
@nguyentu9
nguyentu9 / reset.css
Created July 24, 2021 15:32 — forked from DavidWells/reset.css
CSS reset. Follow me on the twitters for more tips: https://twitter.com/davidwells
/* http://meyerweb.com/eric/tools/css/reset/
v2.0-modified | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
@nguyentu9
nguyentu9 / how-to-learn-wordpress.md
Created December 22, 2020 08:10 — forked from nhim175/how-to-learn-wordpress.md
Các bước tự học Wordpress dành cho CodersX team member

Hướng dẫn tự học Wordpress

Day 1

Mục tiêu

Hiểu các khái niệm cơ bản của Wordpress

Công việc

  • Setup XAMPP
  • Download bản cài wordpress từ wordpress.org về
  • Giải nén vào thư mục htdocs của XAMPP, đổi tên folder thành demo-wordpress hay cái gì đó cũng được
@nguyentu9
nguyentu9 / css-selectors.md
Created November 25, 2020 05:23 — forked from magicznyleszek/css-selectors.md
CSS Selectors Cheatsheet

CSS Selectors Cheatsheet

Element selectors

Element -- selects all h2 elements on the page

h2 {
    foo: bar;
@nguyentu9
nguyentu9 / pagination.md
Created November 5, 2020 17:18 — forked from victorbruce/pagination.md
Paginating, Filtering, and Sorting in React

Pagination

To paginate a page, a general algorithm needs to be followed. Also, you should have the following variables in place:

  • Total items availabe or Items count (It can be a list of patients, books, etc coming from the database)
  • Number of items to display per page or Page size
  • Page count or number of pagination buttons to be rendered (**NB:**This needs to be calculated)

Calculation:

@nguyentu9
nguyentu9 / Firebase.md
Created November 5, 2020 17:17 — forked from victorbruce/Firebase.md
My journey with Firebase so far. Cheatsheet to serve as a quick reference when developing firebase applications

Firebase

Set up firebase and Deploy

  • Head over to firebase. Sign in and create a project.

  • Copy your project settings under Firebase SDK snippet into your local project (ie your project's api key, auth domain, databaseURL, etc)

  • Create a file (firebase.js or config.js Any name that suits you is fine)

@nguyentu9
nguyentu9 / Firebase Database API Cheatsheet
Created November 5, 2020 17:15 — forked from odigity/Firebase Database API Cheatsheet
Firebase Database API Cheatsheet
There is no way to store an empty object/array/null value.
There are also no actual arrays. Array values get stored as objects with integer keys.
(If all keys are integers, it will be returned as an array.)
Basically, it's one giant tree of hashes with string keys.
Simply write a value to any location, and the intermediary locations will automatically come into existance.
── Classes ──
DataSnapshot : Container for a subtree of data at a particular location.