CentOS 7.3
zookeeper-3.4.6 (该部署省略)
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
#!/bin/bash | |
announce () { | |
[[ $verbose -eq 1 ]] && echo "$@" | |
[[ ! -z $logfile ]] && echo "$@" >> "$logfile" | |
} | |
usage() | |
{ |
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
/* | |
gcc -I/usr/local/Cellar/libevent/2.1.8/include/ -L/usr/local/Cellar/libevent/2.1.8/lib/ -levent libevent2-signal.c | |
kill -s USR1 <PID> | |
*/ | |
#include <stdio.h> | |
#include <signal.h> | |
#include <event2/event.h> | |
void cb_func(evutil_socket_t fd, short events, void *arg) |
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
/* | |
brew install libevent | |
gcc -I/usr/local/Cellar/libevent/2.1.8/include/ -L/usr/local/Cellar/libevent/2.1.8/lib/ -levent libevent2-server.c | |
server$ ./a.out | |
client$ telnet 127.0.0.1 8000 | |
*/ | |
#include <event2/listener.h> | |
#include <event2/bufferevent.h> |
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
/* | |
brew install libevent | |
gcc -I/usr/local/Cellar/libevent/2.1.8/include/ -L/usr/local/Cellar/libevent/2.1.8/lib/ -levent libevent2_timer.c | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <sys/time.h> | |
#include <event2/event.h> |
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.Random; | |
class Counter implements Runnable { | |
static int n=0; | |
public static void main(String[] args) { | |
Runnable r = new Counter(); | |
Thread t1 = new Thread(r, "Thread 1"); | |
Thread t2 = new Thread(r, "Thread 2"); | |
t1.start(); |
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.Random; | |
class PrintChar implements Runnable { | |
private String ch; | |
PrintChar(String str) { | |
this.ch=str.substring(0,1); | |
} | |
public void run() { |
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
class ListMetaClass(type): | |
def __new__(cls, name, bases, attrs): | |
attrs['times'] = lambda self, n: self*n | |
return type.__new__(cls, name, bases, attrs) | |
class MyList(list, metaclass=ListMetaClass): | |
pass | |
l = MyList([1,2,3]) | |
print(l.times(2)) |