Skip to content

Instantly share code, notes, and snippets.

View qhwa's full-sized avatar

Qiu Hua qhwa

View GitHub Profile
@qhwa
qhwa / buid-wd-server.sh
Created December 23, 2011 12:42
Build a web developer collaboration server in RedHat
#!/bin/sh
#****************************************************************#
# ScriptName: build-wd-server.sh
# Author: hua.qiuh
# Create Date: 2011-12-02
# Modify Author:
# Modify Date: 2011-12-02
# Function:
#***************************************************************#
@qhwa
qhwa / string-utf8.rb
Created February 1, 2012 07:52
turn string encoding into utf-8 from any charset
class String
def utf8!
%w(ascii-8bit utf-8 ucs-bom shift-jis gb18030 gbk gb2312 cp936).any? do |c|
begin
if self.respond_to? :encode
self.encode!('utf-8', c).force_encoding('utf-8')
else
require 'iconv'
text = Iconv.new('UTF-8', c).iconv(self)
@qhwa
qhwa / dabblet.css
Created April 18, 2012 15:38
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@qhwa
qhwa / dabblet.css
Created April 21, 2012 14:23
CSS3 progress bar
/**
* CSS3 progress bar
* desgin: http://dribbble.com/shots/522214-Progress-Bar
*/
body {
background-image: repeating-linear-gradient(0, #3C3540 0, #3C3540 50%, #38313B 50%, #38313B 100%);
background-size: 3px 1px;
}
.prog-bar {
@qhwa
qhwa / dabblet.css
Created April 21, 2012 15:14
push button example
/**
* push button example
*/
body {
background-color: #0AE;
background-image: linear-gradient(45deg, rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
background-size: 50px 50px
}
.btn {
...
<div id="qunit-fixture">
<a href="#functional-link">#nogo</a>
<a href="http://alibaba.com">grunt</a>
<a href="http://china.alibaba.com">grunt</a>
<a href="http://style.china.alibaba.com">grunt</a>
<a href="http://q.pnq.cc">qhwa</a>
</div>
....
// file: test/grunt-demo_test.js
module('jQuery#ali-link', {
setup: function() {
this.elems = $('#qunit-fixture').children();
}
});
test('is chainable', 1, function() {
strictEqual(this.elems.alilink(), this.elems, 'should be chaninable');
});
test('can select', function() {
// file: test/grunt-demo_test.js
module('jQuery#ali-link', {
setup: function() {
this.elems = $('#qunit-fixture').children();
}
});
test('is chainable', 1, function() {
strictEqual(this.elems.alilink(), this.elems, 'should be chaninable');
});
test('can select', function() {
// file: src/grunt-demo-1.js
(function($) {
var ALI_LINK_REG = /^http:\/\/(.+\.)?alibaba\.com/;
// Collection method.
$.fn.alilink = function() {
return this.each(function() {
var self = $(this);
if( isAliLink(this) ){
self.addClass('ali-link');
} else {
@qhwa
qhwa / 重构前.html.erb
Last active December 14, 2015 08:59
为什么我要重构一个view模板
<!--
这是一个来自真实项目的view模板,
在这里我做了一些简化后,使得阅读更加容易一些。
实际环境中大约是2倍行数。
程序执行时没有错误,一切正常。
美中不足的是,当用户没有登录时,也会显示一个
<span class="message-count"></span> 标签
给用户造成有消息的错觉