Skip to content

Instantly share code, notes, and snippets.

Avatar
🔥
Learning Javascript and algorithm

Aaron youyiqin

🔥
Learning Javascript and algorithm
View GitHub Profile
@JerryC8080
JerryC8080 / RexChainesPhone.js
Created Mar 21, 2016
匹配中国电话号码的正则表达式
View RexChainesPhone.js
/**
电信
中国电信手机号码开头数字
2G/3G号段(CDMA2000网络)133、153、180、181、189
4G号段 177
联通
中国联通手机号码开头数字
@Jaykul
Jaykul / Get-MsdnKeys.ps1
Last active Sep 8, 2021
PowerShell + Selenium Demo: Getting Started, and reusing cookies with Invoke-Request
View Get-MsdnKeys.ps1
# It might work in 4, but I'm not testing there. Lower you'll have to tweak code
#requires -Version 5.0
param(
# Your Live ID for MSDN login
[Parameter(Mandatory)]
[PSCredential]
[System.Management.Automation.CredentialAttribute()]
$Credential,
# Pick a browser to use. Defaults to Firefox (which doesn't seem to require an external Driver file)
@hackjutsu
hackjutsu / example.js
Last active Jul 1, 2021
[Highlight.js + line number] This snippet adds line number support to Highlight.js. Besides, special css trick is applied to stop the line numbers from being selected and copied. #tags: highlight, lepton
View example.js
import HighlightJS from 'highlight.js'
createHighlightedCodeBlock (content, language) {
let lineNumber = 0
const highlightedContent = HighlightJS.highlightAuto(content, [language]).value
/* Highlight.js wraps comment blocks inside <span class="hljs-comment"></span>.
However, when the multi-line comment block is broken down into diffirent
table rows, only the first row, which is appended by the <span> tag, is
highlighted. The following code fixes it by appending <span> to each line
@slikts
slikts / context-vs-redux-2020.md
Last active Dec 12, 2021
Up to date answer about when to use React context or Redux (Redux Toolkit)
View context-vs-redux-2020.md

nelabs.dev

React context vs Redux in 2020

The [React docs][condoc] give some example use cases for context:

Context is designed to share data that can be considered “global” for a tree of React components, such as the current authenticated user, theme, or preferred language.

The common property of these use cases is that data like the current theme doesn't change often and needs to be shared deep down the component tree, which would be cumbersome with "[prop drilling][drill]". Something else that needs to be shared everywhere is the application state when using a "single source of truth" pattern, so it would follow that the context API would help with that as well, but there's a catch: components that use context will rerender every time that the provided value changes, so sharing the whole application state through context would cause excessive render lifecycles.