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
#!/usr/bin/env bash | |
set -x | |
NS="ns1" | |
VETH="veth1" | |
VPEER="vpeer1" | |
VETH_ADDR="10.200.1.1" | |
VPEER_ADDR="10.200.1.2" |
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
# Install Bash 4 using homebrew | |
brew install bash | |
# Or build it from source... | |
curl -O http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz | |
tar xzf bash-4.2.tar.gz | |
cd bash-4.2 | |
./configure --prefix=/usr/local/bin && make && sudo make install | |
# Add the new shell to the list of legit shells |
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 singleton | |
import ( | |
"sync" | |
) | |
type singleton struct { | |
} | |
var instance *singleton |
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
在c 中左移也就是所说的逻辑移位,右端补0,而右移是算数移位,左端补齐的是最高位的符号位。 | |
故负数左移,有可能变成正数,但负数右移,肯定还是负数。 | |
用16进制的形式对数据进行赋值,这16进制的数代表的是补码。 | |
对于signed类型的扩展,看该数据的最高位,为1,则扩展的所有位都为1,为0,则扩展的位都为0,故0xf7扩展成32位是0xfffffff7 |
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
#!/bin/bash | |
tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz | |
export PATH=$PATH:/usr/local/go/bin |
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.util.concurrent.Callable; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.FutureTask; | |
/** | |
* Simple about how to use FutureTask to do some pre-load | |
* task. | |
* |
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.util.concurrent.CountDownLatch; | |
/** | |
* Simple about how to use Latch {@link java.util.concurrent.CountDownLatch} | |
* to control the threads start&stop process. | |
* | |
* @author Tony He | |
*/ |
NewerOlder