Skip to content

Instantly share code, notes, and snippets.

Avatar

WANG Hailei wanghailei

View GitHub Profile
View JavaScript Assert Function
<DOCTYPE html>
<html>
<head>
<title>Test Suite</title>
<style type="text/css" media="screen">
body {
background-color:#000000;
}
#results {
font-family:"OCR A Std"; font-size:10px; text-transform: uppercase;
@wanghailei
wanghailei / gist:4196357
Created Dec 3, 2012
Google Closure - positions sections horizontally with position:absolute
View gist:4196357
app.plateSections = function() {
var plateWidth = 0;
// Add the first section's width.
goog.style.getSize( goog.dom.getFirstElementChild( goog.dom.getElement('plate') ) ).width ;
// Position each of the sections horizontally one after another starting from the first child of plate.
goog.array.forEach( goog.dom.getChildren( goog.dom.getElement('plate') ), function(section) {
goog.style.setPosition( goog.dom.getNextElementSibling(section), goog.style.getPosition(section).x + goog.style.getSize(section).width );
// Accumulate the width of each section after the first section.
plateWidth += goog.style.getSize(section).width;
View gist:4182184
"Having Vim in nocompatible mode, opens a lot of features
:set nocompatible
" Encoding
set fileencodings=utf-8
" Font
:set guifont=Menlo\ 11
@wanghailei
wanghailei / server.go
Created Sep 18, 2012
A simple server in Go
View server.go
package main
import "net/http"
func main() {
panic(http.ListenAndServe(":8080", http.FileServer(http.Dir("/File/Folder/Path"))))
}
View gist:2233246
安装Homebrew(http://mxcl.github.com/homebrew/)。安装之前需要卸掉macports和fink之类的package management systems。
[3/29/12 12:16:31 PM] 王益: 安装方式很简单。一行命令:
/usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
View gist:2011249
.oval {
border-radius: 20px; // Half of a square image's height.
}
@wanghailei
wanghailei / gist:1877164
Created Feb 21, 2012
JS: Mouse Enter and Leave Effect
View gist:1877164
function hover_line() {
$('#left li').mouseenter(function() {
$(this).addClass("hovered");
}).mouseleave(function() {
$(this).removeClass("hovered");
});
}
@wanghailei
wanghailei / procon
Created Feb 9, 2012
Programming Conventions
View procon
1,使用Tab,不使用Space。Tab的宽度自由决定,默认为8个space的宽度。
2,所有的程序注解使用英文,不出现中文。
3,所有文件和文件夹的命名使用小写,使用名词。文件命名尽量使用一个单词;如果必须使用多个单词,单词间用_连接。文件夹命名必须使用一个单词。
4,公共类库高于私有类库。(例如,JavaScript编程必须基于jQuery,基础类不继承自私有类库。)
5,通用编程模式高于私有编程模式。(例如:RESTful架构、MVC模式高于个人创立的模式)
6,标准文件和数据格式高于私有文件和数据格式。(例如:JSON高于自定义的文本格式)
7,任何情况下,简单高于复杂。
8,通常情况下,结构高于效率。
@wanghailei
wanghailei / gist:1480031
Created Dec 15, 2011
SVN with @ in files names
View gist:1480031
find . -name "*@*" | xargs -I % svn add %@
@wanghailei
wanghailei / CSS Only for Firefox
Created Nov 20, 2011
Declare a CSS style just be used for Firefox
View CSS Only for Firefox
@-moz-document url-prefix() {
#search .button_cell input {
height:27px;
padding-bottom:2px;
}
}