Skip to content

Instantly share code, notes, and snippets.

View huruji's full-sized avatar
☂️
被社会毒打的频率奇高

huruji huruji

☂️
被社会毒打的频率奇高
View GitHub Profile
@fokusferit
fokusferit / enzyme_render_diffs.md
Last active April 23, 2025 17:13
Difference between Shallow, Mount and render of Enzyme

Shallow

Real unit test (isolation, no children render)

Simple shallow

Calls:

  • constructor
  • render
@navix
navix / readme.md
Last active August 4, 2023 09:02
TypeScript Deep Partial Interface

TypeScript Deep Partial Interface

export type DeepPartial<T> = T extends Function ? T : (T extends object ? { [P in keyof T]?: DeepPartial<T[P]>; } : T);
type DeepPartial = {
@fstanis
fstanis / index.html
Last active March 16, 2020 03:15
Webpack HTML entry
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="./style.css">
</head>
<body>
@YiqinZhao
YiqinZhao / question-1.js
Last active June 20, 2019 13:38
[yuanfudao-interview] 猿辅导前端面试总结 #interview
let N = 10
let source = []
let M = 4
for (let i = 0; i < N; i++) {
let len = Math.floor(Math.random() * 5) + 5
let item = []
for (let j = 0; j < len; j++) item.push(Math.floor(Math.random() * 10))
source.push(item)
@zxhfighter
zxhfighter / debug.md
Created April 2, 2018 03:15
debug node app

调试 Node 程序

[TOC]

本文介绍的两个调试方法需要 Node 版本大于 6.3.0.

待调试程序

我们来调试下最经典的迷你服务器程序,新建一个文件 app.js,输入内容如下:

@huruji
huruji / miniPromise.js
Created July 13, 2018 17:51
a deom for Promise
function Promise(excutor) {
let self = this;
self.status = 'pending';
self.value = null;
self.reason = null;
self.onFulfilledCallbacks = [];
self.onRejectedCallbacks = [];
function resolve(value) {
if(self.status === 'pending') {
@huruji
huruji / validator-proxy.js
Last active October 8, 2018 18:17
A simple fluent validator using Proxy
var proxyContext = function(ctx) {
return new Proxy(ctx, {
get(obj, prop) {
if (prop in obj) {
return obj[prop];
}
const newCtx = proxyContext(ctx.clone());
if (prop in rules) {
let re = newCtx.addRule(rules[prop]);
return re;
@byevhen2
byevhen2 / Build both .js and .min.js with webpack.md
Last active October 22, 2022 11:58
How to build both minified and uncompressed bundle with Webpack

Q: How to build both minified and uncompressed bundle with Webpack?

A1: Use plugin UglifyJsPlugin (before webpack 4)

let webpack = require("webpack");

module.exports = {
    entry: {
        'bundle': './entry.js',
 'bundle.min': './entry.js'
@aeschright
aeschright / npm-strike.md
Last active September 8, 2021 16:32
A note about npm cli work status

When will [email protected] be released (and other PRs merged?)

On March 22, npm fired several members of the open source and community team for discussing workplace conditions and other labor organizing activities. As a result, core employee contributors to the npm cli were removed from the project, and others have left in solidarity or put their work on hold.

Multiple claims were filed with the NLRB on this matter. The NLRB has investigated and found sufficient evidence of validity to proceed. The National Labor Relations Act of 1935 protects US employees' right to engage in discussions of workplace concerns without threat of retaliation -- and awareness of the importance of how we treat each other is something I valued so much in collaborating with the cli team. How can we work together if we aren't free to discuss what we need?

It's disappointing for all of us to find the work we were doing interrup

import JavaScriptCore
import Foundation
let context = JSContext()!
import JavaScriptCore
@objc protocol MovieJSExports: JSExport {
var title: String { get set }
var price: String { get set }