This file contains hidden or 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 NIOClient { | |
| public static void main(String[] args) throws IOException, InterruptedException { | |
| InetSocketAddress crunchifyAddr = new InetSocketAddress("localhost", 8888); | |
| SocketChannel crunchifyClient = SocketChannel.open(crunchifyAddr); | |
| log("Connecting to Server on port 1111..."); | |
| ArrayList<String> companyDetails = new ArrayList<String>(); | 
  
    
      This file contains hidden or 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
    
  
  
    
  | from fuckconn import redis_conn | |
| import random | |
| ins=redis_conn.get_redis_lab() | |
| cats=['cat'+str(n) for n in range(10)] | |
| hats=['hat'+str(n) for n in range(10)] | |
| for msg in range(10): | |
| cat = random.choice(cats) | |
| hat=random.choice(hats) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import redis | |
| redis_ins = None | |
| def get_redis_lab(): | |
| host = 'redis-13060.c256.us-east-1-2.ec2.cloud.redislabs.com' | |
| port = 13060 | |
| psd = 'pqzuEMkeUz2JPeG2ONBhU004yjtdfUgO' | |
| global redis_ins; | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import java.util.function.Predicate; | |
| import java.util.function.Supplier; | |
| //使用延迟列表 计算素数一个素数列表 | |
| public class DecayComputePrime { | |
| public static void main(String[] args) { | |
| LazyList<Integer> numbers = from(2); | |
| int two = primers(numbers).head(); | |
| int three = primers(numbers).tail().head(); | |
| int four = primers(numbers).tail().tail().head(); | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import java.time.*; | |
| import java.time.format.DateTimeFormatter; | |
| import java.time.temporal.ChronoField; | |
| import java.time.temporal.ChronoUnit; | |
| import java.time.temporal.TemporalAdjuster; | |
| import java.time.temporal.TemporalAdjusters; | |
| import static java.time.temporal.TemporalAdjusters.*; | |
| //新日期API 新的API是Immutable ThreadSafe的 | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import java.util.function.Function; | |
| import java.util.function.UnaryOperator; | |
| //责任链模式 | |
| //同一个对象经过多个链接的处理器,Object ->[HandlerObject1]->[HandlerObject2]->... | |
| //使用lambda expression方式 | |
| public class ChainOfResponsibility { | |
| public static void main(String[] args) { | |
| UnaryOperator<String> header = (input) -> "from Areth,Mario and Alan: "+input; | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import java.util.ArrayList; | |
| import java.util.List; | |
| //观察者模式 | |
| //使用lambda表达式 | |
| public class ObserverDesign { | |
| public static void main(String[] args) { | |
| Subject f = new Feed(); | |
| f.registerObserver(tweet -> { | |
| if (tweet != null && tweet.contains("money")) | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import java.util.*; | |
| import java.util.function.*; | |
| import java.util.stream.Collector; | |
| import java.util.stream.IntStream; | |
| import java.util.stream.Stream; | |
| import static java.util.stream.Collector.Characteristics.CONCURRENT; | |
| import static java.util.stream.Collector.Characteristics.IDENTITY_FINISH; | |
| //自定义Collector模板 | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import lombok.Data; | |
| import java.util.*; | |
| import java.util.function.BiConsumer; | |
| import java.util.function.Function; | |
| import java.util.stream.IntStream; | |
| import static java.util.Comparator.comparingInt; | |
| import static java.util.stream.Collectors.*; | 
  
    
      This file contains hidden or 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
    
  
  
    
  | import java.util.stream.IntStream; | |
| import java.util.stream.Stream; | |
| //Stream生成勾股数,范围1到100 | |
| public class PythagoreanGenerator { | |
| public static void main(String[] args) { | |
| Stream<double[]> pythagorean = IntStream.rangeClosed(1, 100).boxed() | |
| .flatMap(a -> IntStream.rangeClosed(a, 100) | |
| .mapToObj(b -> new double[]{a, b, Math.sqrt(a * a + b * b)}) | |
| .filter(t -> t[2] % 1 == 0) | 
NewerOlder