Skip to content

Instantly share code, notes, and snippets.

View bndynet's full-sized avatar

Bendy Zhang bndynet

View GitHub Profile
@bndynet
bndynet / amd-cmd-umd-commonjs.md
Last active February 21, 2024 13:13
AMD、CMD、UMD、CommonJS

Over the years there’s been a steadily increasing ecosystem of JavaScript components to choose from. The sheer amount of choices is fantastic, but this also infamously presents a difficulty when components are mixed-and-matched. And it doesn’t take too long for budding developers to find out that not all components are built to play nicely together.

To address these issues, the competing module specs AMD and CommonJS have appeared on the scene, allowing developers to write their code in an agreed-upon sandboxed and modularized way, so as not to “pollute the ecosystem”.

AMD(Asynchromous Module Definition)

Asynchronous Module Definition (AMD) has gained traction on the frontend, with RequireJS being the most popular implementation.

Here’s module foo with a single dependency on jquery:

@bndynet
bndynet / ngmodel.md
Last active February 8, 2023 10:28
ngModel in custom component

How to use ngModel in Angular Component?

import { Component, forwardRef } from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';

const noop = () => {
};

export const CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR: any = {
@bndynet
bndynet / unlimited_trials_babeledit.txt
Created January 28, 2021 03:19 — forked from Fusseldieb/unlimited_trials_babeledit.txt
Activate BabelEdit temporarily / Unlimited trial
Obviously for educative purposes only.
Furthermore, this DOESN'T activate BabelEdit permanently.
If you like the software, buy it, the devs deserve it.
Since I have no money to buy it, I discovered a workaround for unlimited trials.
It's quite a annoying workaround, but ... it works!
Firstly go to "c:\windows\system32\drivers\etc\" and open the "hosts" file in Notepad/Notepad++/VSCode/Sublime/Atom/whatever as admin (if you don't open it as admin, it won't let you save it).
Add this line at the end of the file:
@bndynet
bndynet / commit_message_style_guide.md
Last active November 21, 2020 23:26
Commit Message Style Guide

Recommendation for Git Commit Message

The Type

The type is contained within the title and can be one of these types:

  • feat: a new feature
  • fix: a bug fix
  • docs: changes to documentation
  • style: formatting, missing semi colons, etc; no code change
  • refactor: refactoring production code
@bndynet
bndynet / react.md
Last active May 30, 2019 02:20
React Notes

Notes for starting React

React

The Component Lifecycle

Mounting

These methods are called in the following order when an instance of a component is being created and inserted into the DOM:

  • constructor()
@bndynet
bndynet / default.md
Last active May 17, 2019 02:26
JavaScript Unit Testing - Jest

Important issues for Jest

Configurations for DOM Support

Use document object and methods like document.querySelectorAll...

_setup.ts

import "jsdom-global/register";
@bndynet
bndynet / default.md
Last active May 8, 2019 01:33
CSS Arrow

Code for arrows in CSS

.arrow-left {
  display: inline-block;

  
  position: relative;
  width: 0; 
 height: 0; 
@bndynet
bndynet / default.md
Last active May 8, 2019 01:31
Linux Shells

Useful Syntax in Shell

#!/bin/bash

#. ./header.sh
#source ./header.sh

echo `date` # print date
printf "Hello, Shell\n"
@bndynet
bndynet / default.md
Last active April 19, 2019 02:53
Spring Things

Things to Know Getting Started With Spring...

Custom Error

Disabling the Whitelabel Error Page

S1: In application.properties server.error.whitelabel.enabled=false

S2: Excluding the ErrorMvcAutoConfiguration bean

@bndynet
bndynet / default.md
Created April 2, 2019 07:59
React/JSX Style Guide

React/JSX Style Guide

A mostly reasonable approach to React and JSX

This style guide is mostly based on the standards that are currently prevalent in JavaScript, although some conventions (i.e async/await or static class fields) may still be included or prohibited on a case-by-case basis. Currently, anything prior to stage 3 is not included nor recommended in this guide.

Table of Contents

  1. Basic Rules
  2. Class vs React.createClass vs stateless