Skip to content

Instantly share code, notes, and snippets.

View leecade's full-sized avatar
🎯
Focusing

斯人 leecade

🎯
Focusing
View GitHub Profile
@leecade
leecade / install-nodejs.sh
Created August 8, 2012 08:12 — forked from TooTallNate/install-nodejs.sh
Simple Node.js installation script using the precompiled binary tarballs
#!/bin/sh
VERSION=0.8.6
PLATFORM=darwin
ARCH=x64
PREFIX="$HOME/node-v$VERSION-$PLATFORM-$ARCH"
mkdir -p "$PREFIX" && \
curl http://nodejs.org/dist/v$VERSION/node-v$VERSION-$PLATFORM-$ARCH.tar.gz \
| tar xzvf - --strip-components=1 -C "$PREFIX"
@leecade
leecade / unicode.sh
Created August 8, 2012 09:41 — forked from jayli/unicode.sh
将文件一次性转换成unicode编码
#!/bin/sh
# sh ./unicode.sh
# 批量进行unicode转码,主要针对kissy和一些gbk编码的文件来一次性执行操作
# isEnc file.name gbk && echo 'gbk'
# isEnc file.name utf8 && echo 'utf8'
isEnc () {
local temp=`iconv -f $2 $1 1>/dev/null 2>/dev/null && echo 'true'`;
if [ "$temp" = 'true' ]; then
return 0;
fi;
@leecade
leecade / markdown.css
Created August 29, 2012 12:19 — forked from zhimiaoli/markdown.css
github的markdown的样式
.markdown-body {
font-size: 14px;
line-height: 1.6;
}
.markdown-body > *:first-child {
margin-top: 0 !important;
}
.markdown-body > *:last-child {
margin-bottom: 0 !important;
}
@leecade
leecade / v2ex-notification.js
Created September 17, 2012 16:42 — forked from hzlzh/v2ex-notification.js
V2EX notification
/*
@Name: V2EX reply pusher on HTML5 notification API
@URL: http://hzlzh.github.com/project/v2ex-notification/
@Twitter: @hzlzh
*/
// notification close delay time
var AUTO_CLOSE_DELAY_SECONDS = 6, updated_time = '',
refresh_time = 5,
V2EX_RSS = $('.sll').val();
@leecade
leecade / rendering_templates_obsolete.md
Created October 20, 2012 17:02 — forked from jed/rendering_templates_obsolete.md
Rendering templates obsolete

(tl;dr DOM builders like [dom-o][dom-o] trump HTML templates on the client.)

Like all web developers, I've used a lot of template engines. Like most, I've also written a few of them, some of which even [fit in a tweet][140].

The first open-source code I ever wrote was also one of the the first template engines for node.js, [a port][node-tmpl] of the mother of all JavaScript template engines, [John Resig][jresig]'s [micro-templates][tmpl]. Of course, these days you can't swing a dead cat without hitting a template engine; one in eight packages on npm ([2,220][npm templates] of 16,226 as of 10/19) involve templates.

John's implementation has since evolved and [lives on in Underscore.js][underscore], which means it's the default choice for templating in Backbone.js. And for a while, it's all I would ever use when building a client-side app.

But I can't really see the value in client-side HTML templates anymore.

@leecade
leecade / gist:4119687
Created November 20, 2012 18:04
目前基本可用的双拼域名(10,000个左右)
# 某一天心血来潮,想找个好点的双拼域名,于是花了两天跑了160,000左右个组合,有大约10,000个还未被注册,认真地扫了一遍这些域名,结合百度的中文suggestion,居然真的没有一个好点的双拼域名!!!
# 为了尽量让这次无用功最大化,把这些可用的(90%以上)域名放出来,给需要的人~~~
bindiu.com
binguai.com
bingjiong.com
bingreng.com
bingshai.com
bingshei.com
/*!(C) WebReflection *//** @license Mit Style */
// inspired by https://gist.github.com/4395291
this.inherit || (this.inherit = function(create){
if (!create) {
if ({__proto__:null} instanceof Object) {
for (var
Null = function Null() {},
doc = document,
html = doc.documentElement,
iframe = html.insertBefore(
#!/bin/sh
#
cd "/var/www/domain.com/" || exit
unset GIT_DIR
echo "git status info:"
git status
echo "*************************************";

Snow in canvas land

Other people's code is awful, and your own code from months previous counts as someone else's. With this and the festive spirit in mind, I dug up a canvas snow demo I made two years ago to see how bad my code really was.

Turns out the performance landscape has changed quite a bit, but after applying a couple of workarounds, best practices, and memory management, I got the demo running smoother than it ever did.

Ugh, I can't believe I just wrote "performance landscape". Anyway...

How does the demo work?

// OOP
console.log( 'OHAI'.blink() );
// Call invocation
console.log( String.prototype.blink.call('OHAI') );
// $ always makes things look awesome.
var $ = Function.prototype.call;
// Very explicit call invocation