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
using Google.Protobuf; | |
using Grpc.Core; | |
using GrpcGreeter; | |
namespace GrpcGreeter.Services; | |
public class GreeterService : Greeter.GreeterBase | |
{ | |
private static Dictionary<uint, ByteString> responseMap; |
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
// This is a wrk like http benchmarking tool written in C# that supports http/3 | |
using CommandLine; | |
using System.Collections.Concurrent; | |
using System.Diagnostics; | |
using System.Net; | |
using System.Net.Security; | |
using System.Security.Cryptography.X509Certificates; | |
var latencies = new ConcurrentBag<double>(); | |
var failedRequest = new ConcurrentBag<HttpStatusCode>(); |
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
def run(module_path): | |
# run a module | |
# capture standard input and output | |
def wrapper(input): | |
stream_in = StringIO(input) | |
stream_out = StringIO() | |
stdin_ = sys.stdin | |
stdout_ = sys.stdout | |
sys.stdin = stream_in | |
sys.stdout = stream_out |
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
set -x | |
src="/Users/yxr/Downloads/in/" | |
for fullfile in "$src"*.vdat | |
do | |
filename="${fullfile##*/}" | |
output="/Users/yxr/Downloads/out/${filename%.*}.mp4" | |
echo $output | |
ffmpeg -i "$fullfile" -codec copy "$output" | |
done |
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> | |
#include <unistd.h> | |
#include <netdb.h> | |
#include <netinet/in.h> | |
#include <string.h> | |
void error(char *msg) { |
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
//Example code: A simple server side code, which echos back the received message. | |
//Handle multiple socket connections with select and fd_set on Linux | |
#include <stdio.h> | |
#include <string.h> //strlen | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <unistd.h> //close | |
#include <arpa/inet.h> //close | |
#include <sys/types.h> | |
#include <sys/socket.h> |
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> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netdb.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <sys/epoll.h> | |
#include <errno.h> |
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
/*all watcher callbacks have a similar signature | |
callback arguments: | |
1. event loop pointer, or use EV_P_ macro | |
2. the registered watcher structure | |
3. a bitset of received events | |
*/ | |
static void my_cb (struct ev_loop *loop, ev_io *w, int revents) | |
{ | |
// ... | |
// stop watching for events at any time by calling the corresponding stop function ev_TYPE_stop (loop, watcher *) |
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> | |
#include <unistd.h> | |
#include <string.h> | |
#include <netdb.h> | |
#include <netinet/in.h> | |
#include <pthread.h> | |
#define BUFFER_SIZE 1024 |
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> | |
#include <unistd.h> | |
#include <string.h> | |
#include <netdb.h> | |
#include <netinet/in.h> | |
#include <ev.h> | |
#define BUFFER_SIZE 1024 |
NewerOlder