Skip to content

Instantly share code, notes, and snippets.

View dexteryy's full-sized avatar

Dexter Yang dexteryy

View GitHub Profile
@dexteryy
dexteryy / gist:b09597d8ccc4f8d70241
Last active August 29, 2015 14:01
MVC with a unidirectional data flow

Flux + React:

Views ---> (actions) ----> Dispatcher ---> (registered callback) ---> Stores -------+
Ʌ                                                                                   |
|                                                                                   V
+-- (Controller-Views "change" event handlers) ---- (Stores emit "change" events) --+

NervJS + DarkDOM + Templating or Virtual-DOM (React-like):

@dexteryy
dexteryy / gist:7444410
Created November 13, 2013 05:56
gvim/mvim for macvim
# ...
# Last step: fire up vim.
# The program should fork by default when started in GUI mode, but it does
# not; we work around this when this script is invoked as "gvim" or "rgview"
# etc., but not when it is invoked as "vim -g".
if [ "$gui" ]; then
#make macvim open stuff in the same window instead of new ones
if $tabs && [[ `$binary --serverlist` = "VIM" ]]; then
#exec "$binary" -g $opts --remote ${1:+"$@"}
@dexteryy
dexteryy / gist:6503598
Last active December 22, 2015 17:08
对比 accessor API
// jQuery 1.4.4
$('<button></button>').val() // ""
$('<button></button>').val(undefined) // [<button value></button>]
$('<button></button>').val(null) // [<button value></button>]
$('<button></button>').html() // ""
$('<button></button>').html(undefined) // ""
$('<button></button>').html(null) // [<button></button>]
/**
* TUI::ui::slider
* @created: Dexter.Yy
* @modified: $Author$
* @version: $Rev$
*/
/**
* 滑块组件
* @class TUI.widget.slider
@dexteryy
dexteryy / 如何让命令行工具通过代理正常访问github
Created January 23, 2013 12:43
如何让命令行工具通过代理正常访问github
首先你需要一个不怕dns污染的http代理,比如连接到私人VPS的ssh tunnel+privoxy之类…
以下例子里我都使用10.8.0.1:8118作为代理服务器。
## 让普通命令行工具使用代理
可以在~/.profile或~/.bashrc里加上:
```
enable_proxy() {
export http_proxy="10.8.0.1:8118"
@dexteryy
dexteryy / storage.js
Created October 26, 2012 03:04
storage.js
/**
* @import lib/oz.js
* @import lib/jquery.js
* @import mod/event.js
* @import mod/lang.js
*/
define("mod/storageclass", ["lib/jquery", "mod/event", "mod/lang"], function($, Event, _){
var fnQueue = _.fnQueue;
/**
@dexteryy
dexteryy / define_adapter.js
Created September 10, 2012 08:39
AMD -> module pattern
// 这个define的实现会让amd模块声明变成传统的module pattern
function define(fullname, deps, block){
if (!block) {
if (deps) {
block = deps;
} else {
block = fullname;
fullname = [];
}
if (typeof fullname !== 'string') {
@dexteryy
dexteryy / gist:3651272
Created September 6, 2012 04:34
Prometheus deleted scenes
Titles for more than 35 minutes of deleted scenes that will appear on the Prometheus Blu-ray have been discovered at the BBFC via BleedingCool:
DELETED AT THE REQUEST OF 20th CENTURY FOX
00:02:31:16 (ARRIVAL OF THE ENGINEERS) (DELETED SCENE)
00:00:58:05 (T’IS THE SEASON) (DELETED SCENE)
00:00:42:08 (OUR FIRST ALIEN) (DELETED SCENE)
00:00:42:14 (SKIN) (DELETED SCENE)
00:01:22:01 (WE’RE NOT ALONE ANYMORE) (DELETED SCENE)
@dexteryy
dexteryy / chinamap.js
Created March 6, 2012 08:03
Cross-browser Interactive map of China with Raphael.js
/**
* Cross-browser Interactive map of China with Raphael JavaScript Library $Rev$
* Created: dexter.yy
* Modified: $Author$ $LastChangedDate$
* note: 此处为源代码,提交svn时请发布压缩后的版本
*/
(function(){
var mapData = {
heilongjiang: { name: "黑龙江", path: "M432.7,36.8l-4.1-1c-1.2,1.3-2.5,2-4.2,2h-0.3c-1.5,0-2.8-0.5-3.8-1.3l-0.2-0.2v-3.7l-0.3-0.5L418,27l-0.6-3l-0.8-0.2c-2-0.8-3.3-2-3.9-3.8c-0.3-1.2-0.8-2.2-1.5-3.3l-1.3-1.7c-1.1-2.2-2.9-2.7-5.3-1.7c-2.2,1.2-4.3,1.2-6.2,0.4l-1.7-1.1l-1.8-2.2l-0.2-0.3l-0.6-1.7c-1.3-2.4-3.5-4.1-6.7-4.9l-3.8-0.4L373.1,0l-0.2,0.3c-2.1,1.7-4,3.8-5.3,6.7l3,1.1V8h0.2l3.8,0.8l0.3,2l-0.3,0.2l-0.5,0.6l-0.6,0.4l-0.1,0.5l0.8,1.5l1.6,2.4l0.1,1c0.5-1.8,1.7-2.9,3.4-3.4c0,0.8,0.3,1.3,1,1.8l1.3,1.3c0.5,0.2,0.4,0.7-0.6,1.5l-0.6,0.5l-0.3,0.9c-0.2,0.1-0.2,0.4-0.2,0.8v0.5l-0.5,1.6c-0.3,0.6-0.5,1.2-0.6,2.1l0.1,1.1l0.4,0.9l0.3,0.5l1.3,3.3l1,1.7l1.2,0.9l1.1,0.1l3.7-3l1.2-0.7l1.8-0.3l0.6,0.1l3.6,0.2l0.5-0.2l1.1-0.5l0.2-0.8c0.2-1,0.7-2,1.5-3l0.2-0.2c0.4-0.5,1-0.6,1.8-0.5c1.2-0.2,2,0.2,2.5,1c0.2,0.3,0.6,0.5,1,
/**
* TUI::utilities::flash
* @created: Dexter.Yy
* @modified: $Author$
* @version: $Rev$
*/
/**
* @public 获取指定的flash对象
* @note 用于调用flash里提供的方法