Implement of Raft

Hi, I am preparing tech interviews these days, and I am reviewing Raft project I did last semester. I gave a short presentation to others, which is a good way to check if I have a good understanding of the algorithm. And after that, I just want to write a summary by writing this blog.

Before we talk about Raft, we need to talk a little history about Paxos(1980s), a distributed consensus algorithm. The author of Paxos didn’t take the average IQ of people into account, when he declares that Paxos makes things simple! Oppps. The complexity of Paxos has strongly restricted the development, until Raft showed up.

Raft was proposed by Diego and John (Stanford), and this algorithm really makes everything understandable. I will say, it is vivid.

Raft

jbpm example

In some sense, JBPM is simple, because its goal is to offer process management features in a way that both business users and developers like it. Here I will give you a very simple JBPM example with Java action codeblock.

JPDL

There is a JBoss jBPM Process Definition Language file, which defines the topology of the application process.

Suppose one guy(“Tom”) wants to apply for something, he has to submit his application online at the “Apply” task. Then the application form will moves to a certain assignee(Here I name it is “manager”). If the manager says “Yes”, the process moves to the end, and the application successfully ends. If the manager says “No”, the process moves back the “Apply” step, and Tom should apply again (Poor Tom~~).


Vector1

vector类是随标准 C++引入的标准库STL的一个类,它为C++内置数组提供了一种替代方式,为了使用vector 我们必须包含相关的头文件 :

1
#include <vector>

使用vector有两种不同的形式,即所谓的数组习惯和STL习惯。

Delete Node in a Linked List

Question:

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.

Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after calling your function.

####Solution:
The tricky thing is that you can’t trace back in a singly linkded list which lacks “prev” link to node of the previous node. Therefore, we hava to come up with a backup solution to achieve the same result without using “previous” links.

Github菜鸟指南

本文是篇干货,是一个基于linux 命令行操作的github快速使用指南。

GitHub是一个基于Git版本控制工具的免费远程仓库。你可以将个人的开源项目,放到GitHub上分享给世界各地的程序员。同时,GitHub还是一个开源协作社区,通过GitHub,既可以让别人参与你的开源项目,也可以参与别人的开源项目。

在GitHub出现以前,让广大码农群众参与一个开源项目比较困难。当时参与群众也仅限于报个bug,即使能改掉bug,也只能把diff文件用邮件发过去,很不方便。但是在GitHub横空出世之后,利用Git极其强大的Clone克隆和Fork分支功能,广大码农群众真正可以第一次自由参与各种开源项目了。开源运动进入了一个新的高潮。因此,Github被戏称为“世界上最大的同性交友网站”.

喵~~你懂的。Bazinga.


Jason聊Bootstrap:第一话

Bootstrap是Twitter的一个孩子。按照它官方的说法,Bootstrap是一个简洁、直观、强悍的前端开发框架,让web开发更迅速、简单。我觉得Bootstrap流行最好的体现就是,很多网站,尤其是硅谷那些Startup公司的网站,大多采用了Bootstrap的框架进行前端的快速开发,使其看起来简约但不简单。尽管很多优秀的前端设计师已经开始公开抱怨,Bootstrap会溟灭一个公司网站的创意和设计感,使整个IT行业网站千篇一律,但是我觉得Bootstrap是一个非常值得初学者学习的前端综合框架。

目前,Bootstrap已经出到了3.3版本了,想初步了解更多信息,有个更加直观的认识,在国内可以访问其中文的官方地址为:http://v3.bootcss.com。

本文是Jason聊Bootstrap的第一话,旨在告诉大家Bootstrap最基本用法和一些常见的组件的使用。

JavaScript基础(Part 1)

按照惯例,还是先废话一小段。JavaScript是一种轻量级脚本语言,可插入HTML实现网页中的各式各样的动态效果,并为用户提供更流畅美观的浏览效果。之所以叫JavaScript,是因为当年Netscape(网景公司)管理层希望它外观看起来像Java。我个人刚开始学习JavaScript的时候喜欢的JS一个特点,那就是JavaScript是一个弱类型的语言,这样写的时候比较方便,不用关心参数的类别;但是这样对于一个“严肃的程序员”来说确实是不严谨的。

大多数学过C++和Java的朋友,看到JavaScript会两眼放光顿感亲切吧,因为他们觉得JS很好入手,所以我也基本不多废话了,也不班门弄斧了。本文我码了一千字,也仅仅结合一下我自己在学习C++和Java之后,初入JavaScript这样一个新天地时所注意的一些地方。