Skip to content

Instantly share code, notes, and snippets.

View jcouyang's full-sized avatar
🈚
💢

Jichao Ouyang jcouyang

🈚
💢
View GitHub Profile
var Request = require("sdk/request").Request;
var request = function(url, method, data){
var res = $.Deferred();
Request({
url: url,
content: data,
onComplete: function (response) {
res.resovle(response.json);
}
})[method]();
@jcouyang
jcouyang / monad.md
Last active August 29, 2015 14:04
你造Promise 就是 Monad 吗

Monad 这个概念好难解释, 你可以理解为一个 Lazy 或者是状态未知的盒子. 听起来像是薛定谔猫(估计点进去你会更晕了). 其实就是的, 在你打开这个盒子之前, 你是不知道里面的猫处在那种状态.

Monad 这个黑盒子, 里面到底卖的神马药,我们要打开喝了才知道.

等等, 不是说好要解释 Either 的吗, 嗯嗯, 这里就是在解释 Either. 上节说 Either 是一个 Functor, 可以被 fmap over. 怎么这里又说道黑盒子了? 好吧, Monad 其实也是 Functor. 还记得我说的 Functor 其实是一个带 context 的盒子吗. 而 fmap 使得往盒子里应用函数变换成为了可能.

Either

先来看看 Either 这种类型会干什么事情. Either 表示要不是左边就是右边的值, 因此我们可以用它来表示薛定谔猫, 要不是活着, 要不死了. Either 还有个方法: either

@jcouyang
jcouyang / vpn
Last active August 29, 2015 14:03
connect cisco anyconnect in terminal
#!/bin/sh
/opt/cisco/anyconnect/bin/vpn -s $1 blur.blur.com <<"EOF"
0
your.name
your.password
y
exit
EOF
@jcouyang
jcouyang / why-curry-helps.md
Last active February 20, 2023 21:09
为什么要柯里化(why-curry-helps)slide http://git.io/why-curry-helps 📈

还记得 Haskell Curry吗,

多巧啊, 人家姓 Curry 名 Haskell, 难怪 Haskell 语言会自动柯里化, 呵呵. 但是不奇怪吗, 为什么要柯里化呢. 为什么如此重要导致 Haskell 会默认自动柯里化所有函数, 不就是返回一个部分配置好的函数吗.

我们来看一个 Haskell 的代码.

max 3 4
(max 3) 4
@jcouyang
jcouyang / replace_evernote.md
Last active July 9, 2020 01:05
Why do we still need Evernote since there is awesome gist.github.com

I'm a Emacs user and as you may know there is a awesome mode called gist.el, and since then, I found that it's completely my Evernote replacement. Why replace Evernote with gist?

  • code snippet (very significant reason)
  • Version Control, gist actually is a git repo, so you have all the commit history.
  • Social, fork, star, and comment as well.
  • I have emacs open all the time my machine is on. no reason open another app for note taking.
  • annoying Evernote text editor without emacs like shotcut.
  • Github Flavored Markdown(with emoji), or even org-mode and reStructuredText support.

But since there are not so many Emacsers, I create a Atom package glist which do the exact thing as gist.el for Atom.io. as atom support markdown instant preview, note taking with gist is even better.

@jcouyang
jcouyang / 00 Setup Env.md
Last active September 8, 2016 01:44
Build Yourself a Backbone.js Step by Step

Install Node

brew install node

node here is use for setup tools like grunt and mocha

npm install -g grunt

grunt is js build tool.

@jcouyang
jcouyang / atom workspaceView events
Last active May 31, 2018 01:32
the atom workspaceView events
```
application:about: "Application: About"
application:bring-all-windows-to-front: "Application: Bring All Windows To Front"
application:hide: "Application: Hide"
application:hide-other-applications: "Application: Hide Other Applications"
application:minimize: "Application: Minimize"
application:new-file: "Application: New File"
application:new-window: "Application: New Window"
application:open: "Application: Open"
application:open-dev: "Application: Open Dev"
@jcouyang
jcouyang / learnjulia.jl
Last active May 23, 2020 10:20
Y 分钟学 Julia
# 单行注释只需要一个井号
#= 多行注释
只需要以 '#=' 开始 '=#' 结束
还可以嵌套.
=#
####################################################
## 1. 原始类型与操作符
####################################################
@jcouyang
jcouyang / all github 887 emojis.md
Last active February 5, 2018 08:05
all github 887 emoji

💯 👍 👎 🔢 🎱 🅰️ 🆎 🔤 🔡 🉑 🚡 ✈️ ⏰ 👽 🚑 ⚓ 👼 💢 😠 😧 🐜 🍎 ♒ ♈ ◀️ ⏬ ⏫ ⬇️ 🔽 ▶️ ⤵️ ⤴️ ⬅️ ↙️ ↘️ ➡️ ↪️ ⬆️ ↕️ 🔼 ↖️ ↗️ 🔃 🔄 🎨 🚛 😲 👟 🏧 🅱️ 👶 🍼 🐤 🚼 🔙 🛄 🎈 ☑️ 🎍 🍌 ‼️ 🏦 📊 💈 ⚾ 🏀 🛀 🛁 🔋 🐻 🐝 🍺 🍻 🪲 🔰 🔔 🍱 🚴 🚲 👙 🐦 🎂 ⚫ 🃏 ⬛ ◾ :

@jcouyang
jcouyang / 2013-05-25-flash-dd-wrt-and-install-transmission.md
Last active January 21, 2023 07:03
flash dd-wrt and install transmission in WNR2200 router

Prepaire

  • USB disk 格式化成ext2/3格式, with gparted in linux. 根据官方wiki, 最新的v24已经 不用jffs了, 目前的dd-wrt目录结构是这样的:
/tmp ## mounted on the RAM drive of dd-wrt
/jffs  ## builti-in flash, 已经disable
/mnt ## used for rw drive