Skip to content

Instantly share code, notes, and snippets.

View leohxj's full-sized avatar
💯
Focusing

Leo Hui leohxj

💯
Focusing
View GitHub Profile
@leohxj
leohxj / moduleCompatibility.js
Created April 16, 2014 04:41
从knockoutjs源码中读到了一个很好的能兼容AMD,commonjs规范的模块定义。
//闭包执行一个立即定义的匿名函数
!function(factory) {
//factory是一个函数,下面的koExports就是他的参数
// Support three module loading scenarios
if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {
// [1] CommonJS/Node.js
// [1] 支持在module.exports.abc,或者直接exports.abc
var target = module['exports'] || exports; // module.exports is for Node.js
@leohxj
leohxj / .cz-config.js
Last active May 19, 2023 03:49
cz-customizable with emoji
'use strict';
module.exports = {
types: [
{
value: 'WIP',
name : '💪 WIP: Work in progress'
},
{
@leohxj
leohxj / settings.json
Created September 30, 2019 07:49
vsc setting for ngte
{
"editor.fontFamily": "FiraCode-Retina",
"editor.fontLigatures": true,
"editor.fontSize": 18,
"editor.dragAndDrop": false,
"editor.minimap.renderCharacters": false,
"editor.roundedSelection": false,
"editor.quickSuggestions": {
"other": true,
"comments": true,
/*============= Easing =============*/
var easing = {
easeInQuad: function(x, t, b, c, d) {
return c * (t /= d) * t + b;
},
easeOutQuad: function(x, t, b, c, d) {
return -c * (t /= d) * (t - 2) + b;
},
easeInOutQuad: function(x, t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
@leohxj
leohxj / getInitialState.jsx
Last active November 14, 2021 17:24
[react initialState] initState #react
class A extends React.PureComponent {
state = this.getInitialState();
getInitialState() {
const { className } = this.props;
return {
className
};
}
@leohxj
leohxj / dozzle
Created March 13, 2021 04:52
docker logs
docker run --name dozzle -d --volume=/var/run/docker.sock:/var/run/docker.sock -p 4040:8080 amir20/dozzle:latest
@leohxj
leohxj / request.ts
Last active March 5, 2021 08:13
fetch 封装
/* istanbul ignore file */
/* tslint:disable */
/* eslint-disable */
import { ApiError } from './ApiError';
import type { ApiRequestOptions } from './ApiRequestOptions';
import type { ApiResult } from './ApiResult';
import { OpenAPI } from './OpenAPI';
function isDefined<T>(value: T | null | undefined): value is Exclude<T, null | undefined> {
return value !== undefined && value !== null;
@leohxj
leohxj / main.dev.ts
Last active February 26, 2021 02:30
Electron 管理 BrowserView
// xx
const view = new BrowserView()
win.setBrowserView(view)
view.setBounds({ x: 0, y: 0, width: 300, height: 300 })
view.webContents.loadURL('https://electronjs.org')
@leohxj
leohxj / logger.js
Created July 15, 2019 02:11
custom logger
export const logger = (name, ...args) => {
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line
console.groupCollapsed(`logger --> ${name}`);
// eslint-disable-next-line
console.log(...args);
// eslint-disable-next-line
console.groupEnd();
}
};
@leohxj
leohxj / index.html
Last active January 7, 2019 14:44
[todoMVC] dom structure
<section class="todoapp">
<div>
<header class="header">
<h1>todos</h1>
<input class="new-todo" placeholder="What needs to be done?" value="" />
</header>
<section class="main">
<input id="toggle-all" class="toggle-all" type="checkbox" />
<label for="toggle-all"></label>
<ul class="todo-list">