This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function() { | |
var doc = document | |
, frag = doc.createDocumentFragment() | |
, ids = [ | |
{ id: 'tifafa', name: 'tifa' } | |
, { id: 'godlikejay', name: 'Jay' } | |
, { id: 'mockee', name: 'mockee' } | |
].sort(function() { | |
return Math.random() > 0.5 | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*jshint node:true*/ | |
function parse(uaStr) { | |
var agent = { | |
platform: {} | |
, browser: {} | |
, engine: {} | |
} | |
var ua = uaStr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define('mod/ajax', [ | |
'jquery', | |
'mod/cookie' | |
], function($, cookie) { | |
$ = $ || window.$; | |
cookie = cookie || Ark.cookie; | |
function ajax() { | |
var args = arguments, | |
options = args[args.length - 1] || {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define('widget/profile', [ | |
'jquery' | |
, 'mod/cookie' | |
, 'mod/template' | |
], function($, cookie, template) { | |
var body = $('body') | |
, base = $('#ark-console') | |
, header = $('.profile-hd') | |
, dataContainer = $('.profile-bd') | |
, statusBar = $('.profile-ft') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define('mod/bbsync', [ | |
'underscore' | |
, 'mod/ajax' | |
], function(_, Ajax) { | |
function sync(method, model, options) { | |
var url = model.url, data | |
url = _.isFunction(url) ? model.url() : url | |
data = method === 'create' || method === 'update' | |
? model.toJSON() : {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Media Cpature API</title> | |
</head> | |
<body> | |
<input type="file" accept="image/*" capture="camera"> | |
<input type="file" accept="video/*" capture="camcorder"> | |
<input type="file" accept="audio/*" capture="microphone"> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Using new `define.js` | |
// https://gist.github.com/3699759 | |
// Set namespace & module exports aliases | |
define.ns('Ark'); | |
define.config({ | |
'mods/cookie': 'Ark.cookie', | |
'mods/ajax': 'Ark.ajax' | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(win) { | |
var each = function(obj, iterator, context) { | |
if (!obj) { return; } | |
if (Array.prototype.forEach && obj.forEach) { | |
obj.forEach(iterator, context); | |
} else { | |
for (var i = 0, l = obj.length; i < l; i++) { | |
if (i in obj) { | |
iterator.call(context, obj[i], i, obj); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 支持自定义命名空间 | |
Do.setConfig('namespace', 'Ark'); | |
// 利用 `Do` 自身的 `add` 来定义模块的方法名 | |
Do.add('cookie', { path: 'cookie.js' }); | |
Do.add('ajax', { path: 'ajax.js', requires:['cookie'] }); | |
Do('ajax', function() { | |
console.info(Ark.ajax); // Using ajax with cookie mod. | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put this in ~/.zshrc | |
bindkey -v | |
# Put this in ~/.inputrc | |
set editing-mode vi |