Skip to content

Instantly share code, notes, and snippets.

View jcouyang's full-sized avatar
🈚
💢

Jichao Ouyang jcouyang

🈚
💢
View GitHub Profile
@jcouyang
jcouyang / jquery.oauth.js
Last active October 4, 2015 21:08 — forked from andyedinborough/jquery.oauth.js
Introduces $.oauth() to make using OAuth from jQuery as easy as using $.ajax()
(function (window, document, $, undefined) {
if (!$.Deferred) throw 'jQuery 1.5 is required to use the jQuery.oauth script!';
function require(name, url) {
if (window[name] === undefined)
return $.ajax({ type: 'GET', cache: true, dataType: 'script', url: url });
}
console.log("blah")
$.oauth = function (options) {
var d = $.Deferred();
@jcouyang
jcouyang / gist:3931962
Created October 22, 2012 15:13
simple use of closure
We couldn’t find that file to show.
[x/2 for x in range(2,10,2)]
@jcouyang
jcouyang / 2014-01-24-pure-and-secure-javascript-oauth-with-yql.org
Last active August 29, 2015 13:57
pure and secure javascript oauth with yql

It would be awesome if we can use OAuth in JavaScript purely in client side. before start to do that, please let me explain “OAuth2” with this picture in feeeew word (skip to section 2 YQL if you know OAuth2):

http://hueniverse.com/wp-content/uploads/2007/12/My-Endpoints-300x267.png

OAuth 2

OAuth 2 is widely use as authorize third party application without expose user’s password, OAuth2 using 2 steps verification. Take github as example:

There are 2 role in this story: Developer Oyang and User Lulu

@jcouyang
jcouyang / 2013-06-11-use-mock-in-python.markdown
Created March 30, 2014 02:52
How to use Mock testing Python

最近在用 nosetestsmock1 为 bottle 应用测试, 发现几个使用nosetests 要注意的 地方:

1 patch method of module

patch 一个导入 module 的 method, 因为 method 已经被导入到目标文件, 因此必须 要 patch 目标文件的 该方法, 而不是原 module.

@jcouyang
jcouyang / 2013-06-03-how-to-use-octopress-and-write-post-using-org-mode.org
Created April 1, 2014 12:54
How to Write Post Using Octopress Travis CI and Org Mode

getting started

Github page 上建博客本来就是很geek的事情, 用octopress来建博客可用说是 for ruby geeks, 因为可以用欢乐的rake <task> 来完成建立文章和发布等一系 列task. 当然他依赖于 Jekyll

如果wordpress的发布过程是这样的:

  • 打开wordpress
  • 点下new post
  • 在textarea中输入内容
@jcouyang
jcouyang / 2013-06-11-use-mock-in-python.markdown
Created April 1, 2014 13:19
Evernote with emacs and org-mode

最近在用 nosetestsmock1 为 bottle 应用测试, 发现几个使用nosetests 要注意的 地方:

1 patch method of module

patch 一个导入 module 的 method, 因为 method 已经被导入到目标文件, 因此必须 要 patch 目标文件的 该方法, 而不是原 module.

最近再一次偶然的机会在github上见到了这样一个repo http://www.github.com/donnfelker/android-bootstrap 能让你迅速搭建起基本ui和框架.但是基本上没有什么文档,非常可惜.环境搭好 了,却不知道在哪里加代码. 于是我玩几天准备把我的理解写一下,以供找不到文 档的同学可以快速上个手.

101 什么是 android bootstrap

http://www.androidbootstrap.com/images/ab-screenshot.png Android Bootstrap 其实是一堆框架的集合, 让你迅速搭好android 开发的基本

有同学问初学该有个什么starter-kit之类的, 虽然我之前也在用 emacs-starter-kit, 但是那玩意其实对 emacs 24 来说已经很鸡肋了. emacs 24 对包管理这块做的已经足够好,而且源也足够多, 因此, 配置 emacs 24 会变 得容易的多.

我也不知道在哪翻出来的这个 repo, 正好同时解决了新手配置以及文档化的问 题. 所以我决定从 starter-kit 迁过来, 这样以后只用维护

————————–> **这个Org文件** <————————

@jcouyang
jcouyang / 2013-11-27-bdd-using-jasmine-jquery.org
Last active August 29, 2015 13:57
BDD using jasmine jquery

jasmine-jquery 来BDD 就是一个bug, 一个大bug

参加 TWU 时写 jasmine 测试的时候花了大量时间研究为什么不能绑定事件到 fixture. 这导致 teamate 和我自己都会认为我这个带头引入这么难用的 jasmine 的人简直是要杀千刀. 但是其实问题不是 jasmine 当然也不是我, 都是 jasmine-jquery

不管是 loadfixtures 还是 preload(fixtureUrl[, fixtureUrl, …]) 都无法 绑定事件到 fixtures