Skip to content

Instantly share code, notes, and snippets.

View xudaolong's full-sized avatar
🎯
Focusing

Dillon Xu xudaolong

🎯
Focusing
View GitHub Profile
(
(name,msg) => console.log(name,msg)
)("dragon","hello,bird");
(
name => console.log(name)
)("dragon");
let cat = {
name:"tom",
git remote add origin https://github.com/once-work/oncework.git
const express = require('express')
const path = require('path')
const port = process.env.PORT || 8080
const app = express()
// serve static assets normally
app.use(express.static(__dirname + '/public'))
// handle every other route with index.html, which will contain
// a script tag to your application's JavaScript file(s).
@xudaolong
xudaolong / React-CoreRouter.js
Last active January 3, 2019 14:15
React-Webpack 按需加载|-|&tag=react
// FIXME:因为在ComponentsLet中引入了所需的组件,所以不会再单独打包出独立的组件.若工程进一步增加,有必要整理代码
const root_Welcome = {
path: '/Welcome',
getComponent(nextState, cb) {
require.ensure([], (require) => {
cb(null, require('App/Components/Core/Welcome/WelcomeCpt').default)
}, 'Welcome')
}
};
#!/bin/sh
echo $ONCEWORK_CLIPBOARD
git checkout %c%
@xudaolong
xudaolong / fetcherUtil.js&env=js&abbr=`aaa&label=aaa
Last active May 6, 2019 02:18 — forked from LopatkinEvgeniy/fetcher.js
JavaScript-Fetch 优雅使用|-|&tag=Other
import fetch from 'isomorphic-fetch';
// usage : const { status, data, error } = yield fetcher('/api/url');
export default function fetcher(url, options = {}) {
return new Promise((resolve) => {
fetch(url, Object.assign({}, {
credentials: 'same-origin',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
@xudaolong
xudaolong / on-change-url.js&env=plain
Created May 9, 2019 09:57
spa applicaiton listen url change|-|&tag=JS
import _ from 'lodash'
// eslint-disable-next-line no-undef
class URLChangeEvent extends HashChangeEvent {
get [Symbol.toStringTag] () {
return 'URLChangeEvent'
}
}
let urlCache = window.location.href
@xudaolong
xudaolong / Trie.js
Created May 27, 2019 02:30 — forked from deadlocked247/Trie.js
Trie implementation in ES6, good for string autocomplete
/* Class representing a Trie data structure */
export default class Trie {
/**
* Creates a Trie
* @return {Object} Trie
*/
constructor() {
this.words = 0;
this.prefixes = 0;