Skip to content

Instantly share code, notes, and snippets.

@tonyc726
tonyc726 / Array.filter.md
Last active August 29, 2015 13:56
关于arrary.filter学习的一些积累

msdn Array.filter

[1,2,3,4].filter(function(a){
  console.log(this);
  console.log('a:'+a);
  return a!==this[0];
},[2]);
@tonyc726
tonyc726 / 360.html
Last active August 29, 2015 13:56
360浏览器设置Webkit内核
<html>
<head>
<meta name="renderer" content="webkit|ie-comp|ie-stand">
</head>
<body>
</body>
</html>
@tonyc726
tonyc726 / django_charset.md
Last active August 29, 2015 14:01
django GBK 编码总结

django编码问题总结

环境

  1. diango 1.6*
  2. diango-compressor插件 1.4*

**切记:**必须要开始settings.py中的COMPRESS_ENABLED = True,否则编译会报错

HTML实验

@tonyc726
tonyc726 / fs_iconv_gbk.js
Created May 17, 2014 09:58
nodeJS小记
var fs = require('fs');
var iconv = require('iconv-lite');
fs.readFile('./a_uft8.md', function(err, data) {
if (err) {
console.error(err);
} else {
var str = iconv.decode(data, 'utf-8');
var str2 = iconv.encode(str, 'gbk')
var str3 = iconv.decode(str2, 'gbk')
@tonyc726
tonyc726 / CoffeeScript.md
Created May 20, 2014 03:37
CoffeeScript 学习笔记

《CoffeeScript袖珍手册》小记

@(JavaScript)[CoffeeScript]

CoffeeScript常用编程模式

indexOf(*string*)来检测一个值是否存在于一个数组/字符串中

我们常常会使用indexOf()方法来判断一个值是不是属于一个数组, 但由于IE还没有支持, 我们还是需要做一些兼容性的处理.

var included = (array.indexOf("test") != -1)
@tonyc726
tonyc726 / type.coffee
Created May 27, 2014 06:38
通过 Object.prototype.toString.call() 进行类型判断
# http://zhang.zipeng.info/library/coffeescript/07_the_bad_parts.html
# 使用typeof
# 这里是jQuery的$.type的实现的例子
type = do ->
classToType = {}
for name in "Boolean Number String Function Array Date RegExp Undefined Null".split(" ")
classToType["[object " + name + "]"] = name.toLowerCase()
(obj) ->
@tonyc726
tonyc726 / color.js
Created November 6, 2015 06:40
JS随机生成颜色值
function color(){
return '#' + Math.floor(0x1000000 + Math.random() * 0x1000000).toString(16).slice(1);
}
@tonyc726
tonyc726 / JqueryReady.js
Last active December 21, 2015 20:49
动态加载jQuery并等待载入完毕后回调mainFrom http://www.cbrother.com/html/1266.html
/*
动态加载jQuery并等待载入完毕后回调main
Author:McFog
*/
_unique_main = function() {
//maincode with jquery support
}//end of main
if(typeof $ != 'function' || typeof $().jquery != 'string') {
_unique_doc = document.getElementsByTagName('head')[0];
_unique_js = document.createElement('script');
@tonyc726
tonyc726 / 图片垂直居中.html
Last active December 22, 2015 08:38
使用CSS控制图片垂直居中From http://www.jb51.net/web/71728.html
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>图片垂直居中demo</title>
</head>
<style>
/*全局样式*/
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, textarea, p, blockquote, th, td, hr, button, article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { margin: 0; padding: 0; }
body, button, input, select, textarea { font: 12px/1.5 Arial,"microsoft yahei","微软雅黑E\8F6F\96C5\9ED1"; }
@tonyc726
tonyc726 / auto_textarea.html
Last active December 23, 2015 17:19
模拟宽度自适应的输入框 From http://www.css88.com/demo/input-textarea-adaptive/
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
h2 { margin:0; padding:10px 0; font-size:14px; }
.mod-retweet { background:#E4EFF4; border:1px solid #A8D1E0; padding:3px 5px 5px; margin-top:5px; }
.mod-retweet .mod-retweet-textarea { background-color: #FFFFFF; border:1px solid #64B2D1; margin-bottom:5px; overflow:hidden; padding:2px; position:relative; zoom:1 }
.mod-retweet .mod-retweet-textarea textarea {padding: 0;margin: 0; border:0 none; font-size:12px; height:80px; line-height:1.5em; width:100%; display:block }
.mod-retweet .mod-retweet-textarea input { border:0 none; font-size:12px; height:20px; line-height:1.5em; width:100%; }