Skip to content

Instantly share code, notes, and snippets.

View nhducit's full-sized avatar
🚀

nhducit nhducit

🚀
View GitHub Profile
@gaearon
gaearon / quiz.md
Last active January 11, 2024 16:56

A top-level App component returns <Button /> from its render() method.

  1. What is the relationship between <Button /> and this in that Button’s render()?

  2. Does rendering <Button><Icon /></Button> guarantee that an Icon mounts?

  3. Can the App change anything in the Button output? What and how?


const {useCallback, useEffect, useReducer, useRef} = require('react');
let effectCapture = null;
exports.useReducerWithEmitEffect = function(reducer, initialArg, init) {
let updateCounter = useRef(0);
let wrappedReducer = useCallback(function(oldWrappedState, action) {
effectCapture = [];
try {
let newState = reducer(oldWrappedState.state, action.action);
@puzrin
puzrin / Makefile
Last active May 13, 2023 07:17
Makefile example for fontello.com API
# Edit here - set path to you directory with config.json & fonts
FONT_DIR ?= ./assets/vendor/fontello/src
### Don't edit below ###
FONTELLO_HOST ?= https://fontello.com
fontopen:
@if test ! `which curl` ; then \
@GingerBear
GingerBear / react-native-start-with-link.js
Last active January 5, 2023 01:19
start react native bunlder with link
@ohanhi
ohanhi / frp.md
Last active December 23, 2022 13:06
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Editorial note

Important: At the time of writing (2019-11-11) Immutable.js is effectively abandonware, so I can no longer recommend anyone to follow the advice given here. I'll leave the article here for posterity, since it's still getting some traffic.

Understanding Immutable.Record

Functional programming principles and with it immutable data are changing the way we write frontend applications. If the recent de-facto frontend stack of React and Redux feels like it goes perfectly together with immutable data, that's because it's specifically designed for that.

There's several interesting implementations of immutable data for JavaScript, but here I'll be focusing on Facebook's own Immutable.js, and specifically on one of i

@sogko
sogko / app.js
Last active November 8, 2022 12:31
gulp + expressjs + nodemon + browser-sync
'use strict';
// simple express server
var express = require('express');
var app = express();
var router = express.Router();
app.use(express.static('public'));
app.get('/', function(req, res) {
res.sendfile('./public/index.html');
@eddiemoore
eddiemoore / nric-validation.js
Last active October 17, 2022 05:39
Validation for Singapore NRIC and FIN number
//Based on http://www.samliew.com/icval/
function validateNRIC(str) {
if (str.length != 9)
return false;
str = str.toUpperCase();
var i,
icArray = [];
for(i = 0; i < 9; i++) {