Skip to content

Instantly share code, notes, and snippets.

View guo-yu's full-sized avatar
🌉
In Tokyo

Guo Yu guo-yu

🌉
In Tokyo
View GitHub Profile
<!-- 引入menkr cdn 提供的seajs源 和 配置文件 -->
<script src="http://cdn.menkr.com/sea.js" data-config="config/config.js" charset="utf-8"></script>
<script>
// 使用别名(alias)加载组件
seajs.use(['jquery', 'moment'], function($, moment) {
$(document).ready(function() {
console.log('Menkr CDN 上线时间距离现在:')
console.log(moment("20130329", "YYYYMMDD").fromNow())
});
});
@guo-yu
guo-yu / Angular-ngResource.jade
Last active March 17, 2016 02:31
使用Angular进行ngResource模块的注入,并组织一个Store模块进行数据的获取,写入和分析
html(ng-app="app")
head
title demo
body
#wrap(ng-controller="myCtrl")
h1 我是 {{me.name}} , 我已经 {{me.age}} 岁了
@guo-yu
guo-yu / gist:6278806
Created August 20, 2013 08:39
js prototype 继承实例中的参数问题
var Book = function(name) {
this.name = name;
this.demo = '123';
}
var Method = function() {
// 继承了 Book 的静态属性 this.demo = '123'
Book.apply(this, arguments);
}
#include "include.h"
/*
{
"method":"helloworld.onoff",
"params":"on"/"off"
}
*/
@guo-yu
guo-yu / sdk.js
Created September 14, 2013 19:27
var sdk = require('sdk');
// init a API
var demo = new sdk({
read: {
url: '/demo/read/{{name}}',
method: 'get'
},
update: {
url: '/demo/update',
(function ($) {
var rules = document.styleSheets[document.styleSheets.length-1].cssRules;
for (var idx = 0, len = rules.length; idx < len; idx++) {
$(rules[idx].selectorText).each(function (i, elem) {
elem.style.cssText += rules[idx].style.cssText;
});
}
$('style').remove();
$('script').remove();
})(jQuery);
@guo-yu
guo-yu / app.js
Created November 24, 2013 17:09
just require express-scaffold as a server
var server = require('express-scaffold');
// init a new server running on default port 3000
new server({
name: "just another express app",
desc: "some desciption here",
database: {
name: "expressdemo"
}
})
@guo-yu
guo-yu / deps.js
Created November 24, 2013 17:11
a simple dependency injector example
var Depender = require('depender');
dep = new Depender;
dep.define('text', '123');
dep.define('text2', 'demo222222');
dep.define('functionOne', function(msg) {
console.log(msg);
});
dep.use(function(text2, text, functionOne, nonce) {
@guo-yu
guo-yu / parser.js
Created January 24, 2014 16:19
a simple url parser demo
var maps = {
'weibo': 'fa-weibo'
}
var parse = function(url) {
var a = document.createElement('a');
a.href = url;
return a;
}
/**!
* 微信内置浏览器的Javascript API,功能包括:
*
* 1、分享到微信朋友圈
* 2、分享给微信好友
* 3、分享到腾讯微博
* 4、隐藏/显示右上角的菜单入口
* 5、隐藏/显示底部浏览器工具栏
* 6、获取当前的网络状态
*