Skip to content

Instantly share code, notes, and snippets.

View basecss's full-sized avatar
🎯
Focusing

basecss basecss

🎯
Focusing
  • China
  • 06:36 (UTC +08:00)
View GitHub Profile
@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 / 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 / app-download-banner.md
Created February 20, 2014 13:31
显示 app 下载 banner
<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 / 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);
@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 / 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 / autofocus.html
Created November 11, 2013 02:00
autofocus for old browser
<input type="text" id="search" name="" autofocus>
<script type="text/javascript">
(function(inputField){
// typeof inputField.autofocus === 'boolean'
// or !inputField.autofocus
if(inputField.autofocus !== true){
inputField.focus();
}
})(document.getElementById('search'));
@basecss
basecss / simple-dom.js
Created November 11, 2013 14:50
simple DOM handler
(function(win, doc){
var $ = function(selector) {
// 获取元素的方法映射
var matches = {
'#': 'getElementById',
'.': 'getElementsByClassName',
'@': 'getElementsByName',
'*': 'getElementsByTagName',
@basecss
basecss / clone.js
Created November 22, 2013 01:15
Object clone
/*
* 浅复制,子类实例引用类型属性的修改会影响父类对应的属性
*/
function clone(parent, child) {
var i;
child = child || {};
for(i in parent){
if(parent.hasOwnProperty(i)){