Skip to content

Instantly share code, notes, and snippets.

View wanghailei's full-sized avatar

WANG Hailei wanghailei

View GitHub Profile
<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 December 3, 2012 17:03
Google Closure - positions sections horizontally with position:absolute
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;
"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 September 18, 2012 08:33
A simple server in Go
package main
import "net/http"
func main() {
panic(http.ListenAndServe(":8080", http.FileServer(http.Dir("/File/Folder/Path"))))
}
@wanghailei
wanghailei / gist:2233246
Created March 29, 2012 04:18
Install Homebrew
安装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)"
@wanghailei
wanghailei / gist:2011249
Created March 10, 2012 12:12
Oval Image
.oval {
border-radius: 20px; // Half of a square image's height.
}
@wanghailei
wanghailei / gist:1877164
Created February 21, 2012 16:04
JS: Mouse Enter and Leave Effect
function hover_line() {
$('#left li').mouseenter(function() {
$(this).addClass("hovered");
}).mouseleave(function() {
$(this).removeClass("hovered");
});
}
@wanghailei
wanghailei / procon
Created February 9, 2012 02:08
Programming Conventions
1,使用Tab,不使用Space。Tab的宽度自由决定,默认为8个space的宽度。
2,所有的程序注解使用英文,不出现中文。
3,所有文件和文件夹的命名使用小写,使用名词。文件命名尽量使用一个单词;如果必须使用多个单词,单词间用_连接。文件夹命名必须使用一个单词。
4,公共类库高于私有类库。(例如,JavaScript编程必须基于jQuery,基础类不继承自私有类库。)
5,通用编程模式高于私有编程模式。(例如:RESTful架构、MVC模式高于个人创立的模式)
6,标准文件和数据格式高于私有文件和数据格式。(例如:JSON高于自定义的文本格式)
7,任何情况下,简单高于复杂。
8,通常情况下,结构高于效率。
@wanghailei
wanghailei / gist:1480031
Created December 15, 2011 06:18
SVN with @ in files names
find . -name "*@*" | xargs -I % svn add %@
@wanghailei
wanghailei / CSS Only for Firefox
Created November 20, 2011 11:23
Declare a CSS style just be used for Firefox
@-moz-document url-prefix() {
#search .button_cell input {
height:27px;
padding-bottom:2px;
}
}