Skip to content

Instantly share code, notes, and snippets.

View yangg's full-sized avatar

Brook yangg

  • ShenZhen, China
View GitHub Profile
@yangg
yangg / dabblet.css
Created August 29, 2012 02:35
Amazing CSS bubble
/**
* Amazing CSS bubble
*/
body { font:14px/1.6 Lucida Grande,Droid Sans,Verdana,Microsoft YaHei; }
.bubble { height: 120px; width: 400px; left: 20%; }
/* bubble core */
.bubble { position: absolute; border: 1px solid #53a8c9; padding: 10px; min-width: 100px;
border-radius: 5px; box-shadow: 0 0 5px 1px #dbf6ff;
background: #FFF; background: -webkit-linear-gradient(bottom, #e8f5ff, #fff 20px);
@yangg
yangg / linear-gradient.php
Created August 20, 2012 07:08
PHP Functions
<?php
$height = isset($_GET['height']) ? $_GET['height'] : 80;
$width = isset($_GET['width']) ? $_GET['width'] : 80;
// top | left
$dir = isset($_GET['direction']) ? $_GET['direction'] : 'top';
$start = $_GET['start'];
$end = $_GET['end'];
list($r, $g, $b) = hex2rgb($start);
@yangg
yangg / dabblet.css
Created August 20, 2012 03:16
filter - Learning CSS3
/**
* filter - Learning CSS3
*/
dl { float: left; margin: 5px; }
.grayscale img { -webkit-filter: grayscale(100%); }
.sepia img { -webkit-filter: sepia(100%); }
.saturate img { -webkit-filter: saturate(200%); }
.invert img { -webkit-filter: invert(100%); }
.brightness img { -webkit-filter: brightness(1%); }
@yangg
yangg / Colorful.php
Created July 27, 2012 04:42
Markdown & syntax highlighter
<?php
namespace Sundown\Render;
class Colorful extends HTML {
public function blockCode($code, $lang) {
if($lang) {
return self::renderCode($code, $lang);
}
return parent::blockCode($code, $lang);
}
@yangg
yangg / dabblet.css
Created July 2, 2012 01:51
display: box, box-flex - Learning CSS3
/**
* display: box, box-flex - Learning CSS3
*/
/*
* The box-flex property specifies whether the child elements of a box is flexible or inflexible in size.
* Elements that are flexible can shrink or grow as the box shrinks and grows. Whenever there is extra space in a box, flexible elements are expanded to fill that space.
*/
.panel { border: solid 1px #ccc; display: box; }
#p1 { border: solid 1px #f90; box-flex: 3; }
@yangg
yangg / viewsource.cs
Created May 25, 2012 07:35
ViewSource
using System;
using System.Text;
using System.Net;
using System.Text.RegularExpressions;
using System.IO;
class Program
{
static void Main()
{
@yangg
yangg / README.mkd
Created May 23, 2012 03:09
Start emacsclient across multi plaform
windres -O coff icon.rc icon.res
gcc icon.res startemacs.c -o startemacs
@yangg
yangg / uri.js
Created April 24, 2012 05:53 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@yangg
yangg / keyfilter.html
Created April 24, 2012 03:20
Filter User Input by Regex
<!-- tested on chrome & ie9 -->
<input type="text" pattern="\d+" onkeypress="return keyFilter()" />
<input type="text" pattern="\d{11}" maxlength="11" onkeypress="return keyFilter('\\d')" />
<script>
/**
* 限制input的可输入字符类型(不包含长度)
*/
function keyFilter(opt_pat) {
var e = arguments.callee.caller.arguments[0] || window.event,
pattern = opt_pat || (e.target || e.srcElement).getAttribute("pattern");