Skip to content

Instantly share code, notes, and snippets.

Avatar
💯
Focusing

Leo Hui leohxj

💯
Focusing
View GitHub Profile
@leohxj
leohxj / dozzle
Created Mar 13, 2021
docker logs
View dozzle
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 Mar 5, 2021
fetch 封装
View request.ts
/* 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 Feb 26, 2021
Electron 管理 BrowserView
View main.dev.ts
// 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 / settings.json
Created Sep 30, 2019
vsc setting for ngte
View settings.json
{
"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,
@leohxj
leohxj / logger.js
Created Jul 15, 2019
custom logger
View logger.js
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 Jan 7, 2019
[todoMVC] dom structure
View index.html
<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">
@leohxj
leohxj / getInitialState.jsx
Last active Nov 14, 2021
[react initialState] initState #react
View getInitialState.jsx
class A extends React.PureComponent {
state = this.getInitialState();
getInitialState() {
const { className } = this.props;
return {
className
};
}
View deepEquals.js
function deepEquals(a, b, ca = [], cb = []) {
// Partially extracted from node-deeper and adapted to exclude comparison
// checks for functions.
// https://github.com/othiym23/node-deeper
if (a === b) {
return true;
} else if (typeof a === "function" || typeof b === "function") {
// Assume all functions are equivalent
// see https://github.com/mozilla-services/react-jsonschema-form/issues/255
return true;
View mutil-text.css
width: 120px;
flex: auto;
display: -webkit-box;
text-overflow: ellipsis;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
View functionComponent.js
import PropTypes from 'prop-types';
import React from 'react';
import styles from './index.less';
export default function Banner({ hasLogo }) {
const logo = hasLogo ? <div className={styles.logo} /> : null;
return <div className={styles.container}>{logo}</div>;
}