Skip to content

Instantly share code, notes, and snippets.

View nanne007's full-sized avatar
🏠
Working from home

caojiafeng nanne007

🏠
Working from home
View GitHub Profile
@nanne007
nanne007 / StreamOps.scala
Last active August 29, 2015 14:08
这代码写的我一点脾气都没有了
object Stream {
private def interleave[T](s1: Stream[T], s2: Stream[T]): Stream[T] = {
if (s1.isEmpty) s2
else s1.head #:: interleave(s2, s1.tail)
}
private def pairs[S, T](s: Stream[S], t: Stream[T]): Stream[(S, T)] = {
if (s.isEmpty || t.isEmpty) Stream.empty[(S, T)]
(s.head, t.head) #:: interleave(t.tail map ((s.head, _)), pairs(s.tail, t.tail))
}
@nanne007
nanne007 / reset-shift.scala
Created December 16, 2014 02:29
reset/shift in scala
class Shift[+A, -B, +C](val fun: (A => B) => C) {
def map[A1](f: (A => A1)): Shift[A1, B, C] = {
new Shift((k: A1 => B) => fun { (x: A) => k(f(x)) })
}
def flatMap[A1, B1, C1<:B](f: A => Shift[A1, B1, C1]): Shift[A1, B1, C] = {
new Shift((k: A1 => B1) =>
fun { (x: A) => f(x).fun(k) })
}
}
#!/bin/bash
# CentOS rbenv system wide installation script
# Forked from https://gist.github.com/1237417
# Installs rbenv system wide on CentOS 5/6, also allows single user installs.
# Install pre-requirements
yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel \
make bzip2 autoconf automake libtool bison iconv-devel git-core
@nanne007
nanne007 / introrx.md
Last active August 29, 2015 14:22 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

2015-01-29 Unofficial Relay FAQ

Compilation of questions and answers about Relay from React.js Conf.

Disclaimer: I work on Relay at Facebook. Relay is a complex system on which we're iterating aggressively. I'll do my best here to provide accurate, useful answers, but the details are subject to change. I may also be wrong. Feedback and additional questions are welcome.

What is Relay?

Relay is a new framework from Facebook that provides data-fetching functionality for React applications. It was announced at React.js Conf (January 2015).

@nanne007
nanne007 / Enhance.js
Last active August 26, 2015 11:20 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@nanne007
nanne007 / 个人简历.md
Last active February 24, 2016 09:17
个人中文简历

我的简历

个人信息

  • 曹家锋/男/1992
  • 北京邮电大学/13年本科毕业(智能科学与技术专业)、现硕士在读(计算机技术专业)
  • 手机:17710235744/13261499225
  • 邮箱:[email protected]

@nanne007
nanne007 / README.md
Created December 29, 2015 03:27 — forked from JoelQ/README.md
Using Shell Scripts for a Better User Experience (source for https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts)

Server scripts

This is the source for the scripts discussed in https://robots.thoughtbot.com/improving-user-experience-with-shell-scripts

Both scripts are in the bin/ directory of the repo that contains all the markdown documents for blog posts. Users run bin/server and everything is automatically set up for them to view a local preview of the blog. bin/server-setup is a dependency of bin/server and is never run directly by users.

Maitre-d is the name of the "blog engine" discussed in the article.

# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@nanne007
nanne007 / build-emacs.sh
Created May 4, 2016 07:47 — forked from favadi/build-emacs.sh
Compile latest emacs version (24.5) in Ubuntu 14.04
#!/bin/bash
# Build latest version of Emacs, version management with stow
# OS: Ubuntu 14.04 LTS
# version: 24.5
# Toolkit: lucid
# Warning, use updated version of this script in: https://github.com/favadi/build-emacs
set -e