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
@shenqihui
shenqihui / imgLoad.js
Created September 10, 2014 07:34
image load test
var img = document.createElement('img')
img.onload = function() {
console.log('load', img.width, img.height, this);
}
img.src = "https://assets-cdn.github.com/images/octocats/setuptocat.jpg";
@shenqihui
shenqihui / imgonload.js
Created September 16, 2014 02:30
img load
var img = document.createElement('img');
img.onload = function() {
var height = this.height;
var width = this.width;
var src = this.src;
console.log(this, src, width, height);
}
document.body.appendChild(img);
img.src = "http://ww2.sinaimg.cn/bmiddle/86d107cfjw1ekd9ylb8hkg20b40b4e83.gif";
@shenqihui
shenqihui / window.onerror.js
Created November 3, 2014 11:00
window.onerror 监控。
// 监控网页错误情况
//接受三个参数,分别是错误信息,错误页面的url和错误行号
window.onerror = function(errorMessage, scriptURI, lineNumber,columnNumber,errorObj) {
console.log(arguments);
window.a = arguments;
var message = "错误信息: " + errorMessage +
" \n出错文件: " + scriptURI +
"\n出错行号: " + lineNumber +
" \n出错列号:" + columnNumber +
" \n错误详情:" + errorObj.message;
@shenqihui
shenqihui / bind_event.js
Last active August 29, 2015 14:09
bind_event.js
// bind event function
function bind_event(elem, ev, fn) {
//elem object
//ev event
//fn function
if (typeof elem == "undefined" || typeof ev == "undefined" || typeof fn == "undefined" || elem === null) {
return false;
}
if (elem.addEventListener) {
elem.addEventListener(ev, fn, false);
var regex = /gov.cn/ig;
console.log('regex.test("gov.cn")', regex.test("gov.cn"), "gov.cn");
console.log('regex.test("gov.cn")', regex.test("gov.cn"), "gov.cn");
console.log('regex.test("gov.cn")', regex.test("gov.cn"), "gov.cn");
console.log('regex.test("gov.cn")', regex.test("gov.cn"), "gov.cn");
原帖地址: http://topic.csdn.net/u/20110113/19/b0d5d506-4307-428b-a61d-7974aa66a2da.html
首先要说明的是:这里介绍的方法都是大部分是本人“悟”出来的,所以网上难有流传!
好方法不能自己私藏,否则就白忙乎这几天了,分享给有需要的朋友们。如果有转载,敬请注明来自*CSDN老邓*作品。
呵呵,给自己打广告,实在是无耻之极,权当无聊之时打字之用。
欢迎流传,为最优秀的分布式版本管理系统Git做宣传!!
步骤:
1. 下载:http://loaden.googlecode.com/files/gitconfig.7z
2. 解压到:<MsysGit安装目录>/cmd/,例如:D:\Program Files\Git\cmd
@shenqihui
shenqihui / sh.sh
Last active August 29, 2015 14:16
npm install link error
npm install --no-bin-links
@shenqihui
shenqihui / convertCity.js
Last active August 29, 2015 14:16
convertCity from geoip to chinese city
/**
* @name convertCity
* @desc 进行 geoip 到 中文 city 的转换。源变量污染式修改。
* @depend []
* @param { obj } obj 用于转换的数据
* @return { obj } 返回一个新的已经是中文名的 obj 。
**/
function convertCity(obj) {
var geoipcity = {
@shenqihui
shenqihui / cookie_reset.js
Last active August 29, 2015 14:16
reset cookies
'''
given a Model with:
category = models.CharField(max_length=32, choices=CATEGORY_CHOICES)
pubdate = models.DateTimeField(default=datetime.now)
<other fields>
Fetch the item from each category with the latest pubdate.
'''