This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Distributed systems are different because they fail often. What sets distributed systems engineering apart is the probability of failure and, worse, the probability of partial failure. Networked systems fail more than systems that exist on only a single machine and that failures tend to be partial instead of total. Design for failure. | |
2. Writing robust distributed systems costs more than writing robust single-machine systems. There are failure conditions that are difficult to replicate on a single machine. Distributed systems tend to need actual, not simulated, distribution to flush out their bugs. Simulation is, of course, very useful. | |
3. Robust, open source distributed systems are much less common than robust, single-machine systems. | |
4. Coordination is very hard. Avoid coordination machines wherever possible. This is often describled as "horizontal scalability". The real trick of horizontal scalability is independence - being able to get data to machines such that communication and consensus between t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.xqbase.java; | |
/** | |
* LeetCode02 -- Add Two Numbers | |
* | |
* @author Tony He | |
*/ | |
public class AddTwoNumbers { | |
public static class ListNode { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BoundedHashSet<T> { | |
private final Set<T> set; | |
private final Semaphore sem; | |
public BoundedHashSet(int bound) { | |
set = Collections.synchronizedSet(new HashSet<T>()); | |
sem = new Semphore(bound); | |
} | |
public boolean add(T o) throw InterruptedException { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.xqbase.java; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.PushbackInputStream; | |
import java.util.zip.GZIPInputStream; | |
public class CheckGZIPStream { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl http://nodejs.org/dist/<version>/node-<version>.tar.gz | |
tar zxvf node-<version>.tar.gz | |
cd node-<version> | |
./configure | |
make | |
[sudo] make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
fs = require('fs'), | |
parse = require('url').parse; | |
function upload(url, filePath, callback) { | |
var urlObj = parse(url), | |
path = urlObj.pathname + (urlObj.search || ''), | |
options = { | |
hostname: urlObj.hostname, | |
path: path, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
parse = require('url').parse; | |
function requestUrl(url, callback) { | |
var urlObj = parse(url), | |
path = urlObj.pathname + (urlObj.search || ''), | |
options = { | |
hostname: urlObj.hostname, | |
path: path, | |
port: urlObj.port || 80, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in UNIX system, there are three special file descriptors, | |
they are stdin, stdout, stderr, and the corrsponding file | |
descriptors are 0, 1, 2, and they are store in the corrsponding | |
FILE struct. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int power(int m, int n); | |
int main() { | |
int m, n; | |
system("clear"); | |
printf("Enter two numbers:\n"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ado.java; | |
public class TestRef { | |
public static void main(String[] args) | |
{ | |
ValueObject vo1 = new ValueObject("A", 1); | |
System.out.println("after vo1: " + vo1.getName()); //=A | |
changeValue1(vo1); |
NewerOlder