Skip to content

Instantly share code, notes, and snippets.

View shenqihui's full-sized avatar
💭
I may be slow to respond.

大饼 shenqihui

💭
I may be slow to respond.
View GitHub Profile

常用的 HTML 头部标签

详细介绍参见原文:yisibl/blog#1

<!DOCTYPE html> <!-- 使用 HTML5 doctype,不区分大小写 -->
<html lang="zh-cmn-Hans"> <!-- 更加标准的 lang 属性写法 http://zhi.hu/XyIa -->
<head>
    <meta charset='utf-8'> <!-- 声明文档使用的字符编码 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <!-- 优先使用 IE 最新版本和 Chrome -->
@shenqihui
shenqihui / date.valid.js
Created May 20, 2014 10:08
Valid or Invalid Date
var a = '20140531';
var str = a.substring(0,4)+'-'+a.substring(4,6)+'-'+a.substring(6);
var date = new Date(str);
date.getFullYear() === date.getFullYear();
var video = document.getElementById("video");
function getCurTime() {
console.log(video.currentTime);
setTimeout(getCurTime, 200);
}
getCurTime()
/**
* @name
* @desc 页码组装
* @depend ['jQuery']
**/
;(function() {
var pageTemp = 1, hash = location.hash;
if( /^#page=\d+$/.test(hash) === true ){
pageTemp = parseInt( hash.substring(6) );
"use strict";
var util = util || {};
// cookie 相关函数
util.setCookie = function(name, value, expiredays) {
var exdate = new Date()
exdate.setDate(exdate.getDate() + expiredays)
document.cookie = name + "=" + escape(value) +
((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
}
$(window).on('hashchange', function(e) {
if (location.hash === '#login') {
location.hash = "#loginTrue";
} else if (location.hash === '#reg') {
location.hash = "#regTrue";
} else if (location.hash === '#find') {
location.hash = "#findTrue";
}
})
@shenqihui
shenqihui / virailssource
Created July 20, 2014 05:05
修改 ruby rails 的 Gemfile template,是source指向 ruby.taobao.org/
#cd $rails_path
#例如
cd /home/vagrant/.rvm/gems/ruby-2.1.0/gems/railties-4.1.4
vi ./lib/rails/generators/rails/plugin/templates/Gemfile
vi ./lib/rails/generators/rails/app/templates/Gemfile
# change source 'https://rubygems.org' into source 'https://ruby.taobao.org/'
@shenqihui
shenqihui / pushState
Last active August 29, 2015 14:04
history.pushState
history.pushState
@shenqihui
shenqihui / blurred_answer
Created July 31, 2014 06:33
blurred_answer by quora
.blurred_answer .para_block {
filter: blur(6px);
-webkit-filter: blur(6px);
-moz-filter: blur(6px);
-o-filter: blur(6px);
-ms-filter: blur(6px);
/* filter: url(/static/firefox-blur.svg#blur); */
margin-bottom: 30px;
margin-left: 5px;
width: 495px;
@shenqihui
shenqihui / excape.js
Last active August 29, 2015 14:06
escape any html tap. 转义部分tap
$('textarea')
.val()
.replace(/<([/^<>]*?((script)|(style)|(link)|(img)|(object)|(embed)|(textarea)|(input))[^<>]*?)>/g,"&lt;$1&gt;")
.replace(/\n/g,"<br>");