##Intro to Redux
###Some important concepts of Redux
Reference: Three Principles, Basics
- A single Store to maintain the state tree
function loadOrFallback(scripts,idx) { | |
var successfully_loaded = false; | |
function testAndFallback() { | |
clearTimeout(fallback_timeout); | |
if (successfully_loaded) return; // already loaded successfully, so just bail | |
try { | |
scripts.tester(); | |
successfully_loaded = true; // won't execute if the previous "test" fails | |
scripts.success(); | |
// console.log("success: " + scripts.src[idx]); |
p{ | |
width: 220px; | |
margin: 0; | |
} |
def lcs(x, y): | |
n = len(x) | |
m = len(y) | |
table = dict() # a hashtable, but we'll use it as a 2D array here | |
for i in range(n+1): # i=0,1,...,n | |
for j in range(m+1): # j=0,1,...,m | |
if i == 0 or j == 0: | |
table[i, j] = 0 | |
elif x[i-1] == y[j-1]: |
import math | |
def kthPrime(k): | |
# k is non-negative | |
if k < 0: | |
return None | |
# an array to store primes | |
primes = [] | |
# use an array of booleans `isPrime` to indicate whether a number is a prime | |
# e.g. isPrime[2] is True means 2 is a prime | |
# upperLimit is the size of the array. We start from a small number |
var $container = $('#container'); | |
... | |
// when some route is matched | |
var view = new AnotherPage(); | |
$container.html(view.render().el); | |
window.scrollTo(0, 0); | |
$container.html(el) | |
// jump to top if needed |
##Intro to Redux
###Some important concepts of Redux
Reference: Three Principles, Basics
const lodash = require('lodash'); | |
const { random } = lodash; | |
const online = [] | |
const offline = [] | |
const afk = [] | |
function addPlayer(set, fixPower) { | |
set.push({ | |
power: fixPower || random(1, 1000, true), |
function runScriptable() { | |
const [title, link] = getZoomInfo(new Date()); | |
const widget = createWidget(title, null, link); | |
if (config.runsInWidget) { | |
Script.setWidget(widget); | |
Script.complete(); | |
} else { | |
widget.presentSmall(); | |
} |
" Don't try to be vi compatible | |
set nocompatible | |
" Helps force plugins to load correctly when it is turned back on below | |
filetype off | |
" TODO: Load plugins here (pathogen or vundle) | |
" Turn on syntax highlighting | |
syntax on |
我一直很佩服能坚持写作的人。我自己写东西的时候八成都是这样的三部曲:产生强烈的表达冲动——越写越觉得自己的想法和表达有缺失——把半成品忘在草稿箱里。
今年我下决心无论如何都要把年终总结写出来,因为在生活的方方面面都发生了太多重要的事了。但是写着写着又开始自我怀疑:说了这么多事,好像每个都有点感悟,又每个都没写清楚,这算个什么哪门子的文章?正这么想的时候在推特上看到了 Rick Rubin 的一个视频叫作《How to deal with a creative block》。他鼓励内容创作者写东西就当作写日记,只为自己一个人写,认真写,不用为别人负责。
谢谢 Rubin,谢谢宇宙。这篇总结我就为了自己写。