Skip to content

Instantly share code, notes, and snippets.

@ericdum
ericdum / dabblet.css
Created December 6, 2012 13:32
Untitled
div{
width:200px;
padding: 5px 0 0 5px;
_padding-left: 10px;
border: none;
}
a{
float: left;
line-height: 20px;
margin: -5px 0 0 -5px;
@ericdum
ericdum / dabblet.css
Created December 6, 2012 13:52
Untitled
div{
width:200px;
padding: 5px 0 0 5px;
_padding-left: 10px;
border: none;
}
a{
float: left;
line-height: 20px;
margin: -5px 0 0 -5px;
[
{
name:"HTML5",
uri:"http://www.w3.org/TR/html5/single-page.html",
category:"markup"
},
{
name:"HTML 5.1",
uri:"http://www.w3.org/TR/html51/single-page.html",
category:"markup"
@ericdum
ericdum / pre-commit
Last active December 19, 2015 09:09
git commit的时候,刷新css中的资源:图片什么的。如:如果提交发现对anywhere/header.png有更改,那么搜索包含header.png的css文件,然后匹配css中的header.png是否为同一个文件,如果是:加上时间戳以更新缓存。 未完:更改文件后无法加入本次commit。待解决
#!/bin/sh
#刷新css中的资源:图片什么的
#检查流程:
# 1. 检查变更的资源文件 git status -s
# 2. 将取得的文件名在所有css文件中进行搜索
# 3. 在匹配的css中取得符合的资源相对路径
# 4. 检查相对路径指向的是否为目标文件
# 5. 更新匹配的相对路径的时间戳为当前时间
root=`pwd`
//红黑树, 二叉树改写而来
/***************************result************************
*
* 中序遍历红黑树:
* value=3 color=RED parent=7
* value=7 color=BLACK parent=10 left=3
* value=10 color=RED parent=14 left=7 right=12
* value=12 color=BLACK parent=10
* value=14 color=BLACK parent=17 left=10 right=16
* value=15 color=RED parent=16
@ericdum
ericdum / pointInPolygon.js
Created October 11, 2013 09:54
Point in Polygon
function isPointInPath(x, y, poly){
var num = poly.length,
i = 0,
j = num - 1,
c = false;
for( ; i < num; ++i ) {
if ( ((poly[i][1] > y) != (poly[j][1] > y))
&& (x < (poly[j][0] - poly[i][0]) * (y - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0]))
c = !c;
j = i;
@ericdum
ericdum / Zero-lines-JS-game.markdown
Created November 23, 2013 06:01
A Pen by Alexander Majorov.
@ericdum
ericdum / analytics_specs.js
Created November 24, 2013 02:00
将第一个CSV字符串参数,按纵横比分类。 测试数据:"120×240 ,120×600 ,,160×600 ,200×200 ,250×250 ,300×250 ,336×280 ,468×60 ,728×90 ,970×90 ,,120×240 ,180×150 ,234×60 ,300×600 ,,160×600 ,250×250 ,300×250 ,336×280 ,468×60 ,640×90 ,728×90 ,760×90 ,950×90 , ,120×240 ,250×300 ,300×100,660×90 ,250×180,600×90,650×90 ,360×300,500×200,,1000×90 ,960×90 ,300×250 ,220×120 ,300×50 ,…
/**
*
* 将第一个CSV字符串参数,按纵横比分类
* usage: analytics_specs("800*1600, 400*800, 800*2000", "x", ",")
*/
function analytics_specs( string, a, b ) {
a = a || '×';
b = b || ',';
@ericdum
ericdum / test-for.js
Last active August 29, 2015 13:58
test-for.js
var timers = {};
if ( console && !console.time ) {
console.time = function( name ) {
if ( name ) {
timers[ name ] = Date.now();
}
}
console.timeEnd = function( name ) {
if ( timers[ name ] ) {
console.log( name + ': ' + (Date.now() - timers[ name ]) + 'ms' );
<!doctype html>
<html>
<body>
<script>
var timers = {};
var _console = {};
var _console_cache = [];
_console.time = function( name ) {
if ( name ) {
timers[ name ] = (new Date());