Skip to content

Instantly share code, notes, and snippets.

View yuanchuan's full-sized avatar

Yuan Chuan yuanchuan

View GitHub Profile
@yuanchuan
yuanchuan / program1.js
Created August 10, 2012 07:42
判断QQ在不在线
/*========================================
* API (普通的方式)
*=======================================*/
check(qq, function(on) {
if (on) {
} else {
}
@yuanchuan
yuanchuan / gist:3998675
Created November 2, 2012 04:13
Experimental problem solving with MongoDB
/**
* Experimental problem solving with MongoDB
*
* 描述:
*
* 假设现在有百万级的数据,每个数据存储着用户的信息(可以是简易的信息),
* 每个数据中含有一个用户的ID,还有一个特殊数据,我们可以将这个数据叫做“等级”。
* 现在 我们的需求是:
* 1,根据一个用户ID能快速找出该用户信息
* 2,根据一个用户ID能快速找出比该用户的“等级”低的最靠近他的10名别的用户,和找出比该用户“等级”高的10名用户
@yuanchuan
yuanchuan / Contract Killer 3.md
Created November 7, 2012 13:33
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

/**
例如 prezero(200) 返回 0200
*/
var prezero = function(number) {
var str = number.toString(10);
var len = str.length;
while((len++) < 4) {
str = '0' + str;
/**
* 1. 打开百姓网首页,http://www.baixing.com
* 2. 把下面这段代码复制到控制台并运行(需要chrome :D),
* 3. 然后鼠标移动到 LOGO 上可以看到效果
*/
(function() {
if (!document.createElement('canvas').getContext) return false;
@yuanchuan
yuanchuan / gist:5641197
Created May 24, 2013 03:54
note for ie8 quirks
/* Both */
li:last-child, li.last-child {
border: none;
}
/* AND */
li.last-child, li:last-child {
border: none;
#/bin/sh
visit() {
awk '!/POST|scripts|images|styles|admin|logshare/ { print $1; }' $1
}
shake() {
awk '/POST/ && /shake/ { print $1; }' $1
}
count() {
wc -l | awk '{print $1}'
@yuanchuan
yuanchuan / gist:85554d7f36795558da60
Last active August 29, 2015 14:00
Interstellar Movie - Official Teaser
We’ve always defined ourselves by the ability to overcome the impossible.
And we count these moments.
These moments when we dare to aim higher, to break barriers, to reach for the stars, to make the unknown known.
We count these moments as our proudest achievements.
Are we lost on that?
Perhaps, we’ve just forgotten that we are still pioneers.
And we’ve barely begun.
And that our greatest accomplishments cannot be behind us, because our destiny lies above us.

Keybase proof

I hereby claim:

  • I am yuanchuan on github.
  • I am yuanchuan (https://keybase.io/yuanchuan) on keybase.
  • I have a public key whose fingerprint is 4D7B C6B5 CE47 FC6D 06A7 9350 8355 451C E446 6990

To claim this, I am signing this object:

var notify = (function() {
var origin = document.title.replace(/^\(\d\)?/, '');
var pattern = '(*) ';
return {
clear: function() {
document.title = origin;
},
count: function(n) {
document.title = pattern.replace('*', n) + origin;
}