Skip to content

Instantly share code, notes, and snippets.

View basecss's full-sized avatar
💻

basecss basecss

💻
  • China
  • 15:19 (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

@basecss
basecss / html_head.html
Created December 17, 2013 01:13
html head
<!DOCTYPE html> <!-- HTML5 doctype 不区分大小写 -->
<html lang="zh-cmn-Hans-CN"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 优先使用IE最新版本和 Chrome -->
<!-- width=device-width 会导致 iPhone 5 添加到主屏后以 WebAPP 全屏模式打开页面时出现黑边 http://bigc.at/ios-webapp-viewport-meta.orz -->
<meta name ="viewport" content ="initial-scale=1.0, maximum-scale=3, minimum-scale=1, user-scalable=no">
@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;
}
@basecss
basecss / loadScript-usage.md
Last active March 14, 2016 02:52
动态载入脚本

loadScript()方法每次只能载入一个文件,在载入多个文件的时候除了FireFox和Opera能够按照指定的顺序执行脚本。其他都懒起都无法按照指定顺序执行脚本。可以使用嵌套回调的方式解决这个问题。

loadScript('a.js', function(){
	loadScript('b.js', function(){
		loadScript('c.js', function(){
			loadScript('d.js', function(){
				// do something
			});
 });

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

代码

new Array(101).join(' ').replace(/ /g,function(t,i){
    return i+1+' '
}).split(' ').reduce(function(n1,n2) {
    return (n1-0)+(n2-0)
});
@basecss
basecss / localStorage.js
Created January 26, 2014 12:55
localStorage
function localStorageSupport() {
try {
return ('localStorage' in window && window['localStorage'] !== null)
} catch(e) {
console.log(e.stack);
}
return false;
}
function addData(key, data) {
@basecss
basecss / localStorageSpace.js
Created January 26, 2014 11:44
check localStorageSpace
var localStorageSpace = function(){
var data = '';
for(var key in window.localStorage) {
if(window.localStorage.hasOwnProperty(key)) {
data += window.localStorage[key];
console.log(key + ' = ' + ((window.localStorage[key].length * 16) / (8 * 1024)).toFixed(2) + ' KB');
@basecss
basecss / loop.less
Created January 18, 2014 17:22
loop for less
.loop(@index) when (@index > 0) {
selector:nth-child(@index) {
property: @index * 1px; // use @index
}
.loop(@index - 1); // 递归
}
// Example
.loop(@index) when (@index > 0) {
@basecss
basecss / dabblet.css
Created November 25, 2013 06:26
iOS7 style checkbox and radio
/*
* iOS7 style checkbox and radio
*/
body {
margin:30px;
}
input[type=checkbox], input[type=radio] {
appearance: none;
-webkit-appearance: none;
box-shadow: inset 0px 0px 0px 1px #e6e6e6;
@basecss
basecss / dabblet.css
Created November 22, 2013 06:01
dabblet.com 预览 gist 代码片段
body {
margin: 0;
padding: 0;
background: #09F;
}
.dialog {
position: absolute;
left: 50%;
top: 50%;
width: 500px;