Skip to content

Instantly share code, notes, and snippets.

View basecss's full-sized avatar
💻

basecss basecss

💻
  • China
  • 03:57 (UTC +08:00)
View GitHub Profile
@basecss
basecss / setup.md
Last active November 29, 2018 12:20
React + Redux + Webpack + Babel + HMR(JS + CSS) + CSS Extract

dependencies

npm install webpack webpack-cli webpack-dev-server @babel/core @babel/preset-env
@babel/preset-react babel-loader css-loader mini-css-extract-plugin css-hot-loader --save-dev --verbose

npm install react react-dom redux react-redux --save --verbose

.babelrc

群主分享了这么一段代码,应邀分析一下,以下是正文。

代码

new Array(101).join(' ').replace(/ /g,function(t,i){
    return i+1+' '
}).split(' ').reduce(function(n1,n2) {
    return (n1-0)+(n2-0)
});
@basecss
basecss / install.md
Created March 6, 2015 02:46
Install different version of Node.js
// Install n from npm
$ sudo npm install -g n

// Install different version for Node.js
$ sudo n 0.12.0
$ sudo n 0.10.36

// Quickly switch between the Node.js version with the command n
$ n
@basecss
basecss / vhost-config.md
Created January 4, 2015 07:21
Windows下配置vhost(WAMP)
  • /Apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "F:/xxx/xxx" <- code
    ServerName myhost.example.com
    ErrorLog "logs/myhost.example.comm-error.log"
    CustomLog "logs/myhost.example.com-access.log" common
@basecss
basecss / promise.md
Created July 10, 2014 10:31
JavaScript Promise
function fetchJSON(url) {
	return new Promise(function(resolve, reject) {
		var xhr = new XMLHttpRequest();
		xhr.open('GET', url);
		xhr.responseType = 'json';
		xhr.send();
		xhr.onload = function() {
			if(xhr.response) {
 resolve(xhr.response);
<style>
@media (min-device-width:600px) {
img[data-src-600px] {
content: attr(data-src-600px, url);
}
}
@media (min-device-width:800px) {
img[data-src-800px] {
content: attr(data-src-800px, url);
@basecss
basecss / app-download-banner.md
Created February 20, 2014 13:31
显示 app 下载 banner
@basecss
basecss / deepClone.js
Created February 13, 2014 04:11
deep clone object
function deepClone(target) {
if(typeof target !== 'object') {
return target;
}
if(target.constructor === RegExp) {
return target;
}
var result = new target.constructor();
@basecss
basecss / sidebar.md
Created February 10, 2014 05:10
FireFox 浏览器 - 添加到书签栏
<a href="http://www.basecss.net/" rel="sidebar">收藏本站</a>

目前只有 FireFox 支持,新版 Opera 启用 Webkit 内核之后已经不再支持。

@basecss
basecss / createTouchEvent.js
Created January 28, 2014 12:16
createTouchEvent
(function() {
var ua = /iPhone|iP[oa]d/.test(navigator.userAgent) ? 'iOS' : /Android/.test(navigator.userAgent) ? 'Android' : 'PC';
document.addEventListener('DOMContentLoaded', function(event) {
if(ua === 'PC') {
return;
}