Skip to content

Instantly share code, notes, and snippets.

View junxie6's full-sized avatar
🐢
Push the limits of what's possible. Today.

Jun Hsieh junxie6

🐢
Push the limits of what's possible. Today.
View GitHub Profile
@junxie6
junxie6 / coro.c
Created September 25, 2021 20:14 — forked from lpereira/coro.c
Simple coroutine implementation in C
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <ucontext.h>
typedef struct coro_t_ coro_t;
typedef struct thread_t_ thread_t;
typedef int (*coro_function_t)(coro_t *coro);
typedef enum {
CORO_NEW,
@junxie6
junxie6 / openssl_2way_auth.sh
Created September 8, 2021 03:00 — forked from zapstar/openssl_2way_auth.sh
Steps to create CA, server and client keys + certificates for SSL 2-way authentication
# Move to root directory...
cd /
mkdir keys
cd keys
# Generate a self signed certificate for the CA along with a key.
mkdir -p ca/private
chmod 700 ca/private
# NOTE: I'm using -nodes, this means that once anybody gets
# their hands on this particular key, they can become this CA.
@junxie6
junxie6 / client.go
Created June 28, 2021 00:55 — forked from xjdrew/client.go
golang tls client and server, require and verify certificate in double direction
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io"
"io/ioutil"
"log"
"os"
@junxie6
junxie6 / array.c
Created May 11, 2021 04:34 — forked from FurryHead/array.c
Dynamic array and map in C.
#include <string.h>
#include <stdlib.h>
#include "array.h"
typedef struct array array;
typedef struct map map;
/** @brief Allocates and initializes a new array */
array *array_new(void) {
array *tmp = malloc(sizeof(array));
@junxie6
junxie6 / array.c
Created May 11, 2021 04:30 — forked from matugm/array.c
dynamic arrays in c
#include "array.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
struct ArrayData *initArray() {
struct ArrayData *newArray = malloc(sizeof(struct ArrayData));
newArray->pointer = calloc(1000, sizeof(int));
newArray->size = 1000;
0 = Success
1 = Operation not permitted
2 = No such file or directory
3 = No such process
4 = Interrupted system call
5 = Input/output error
6 = No such device or address
7 = Argument list too long
8 = Exec format error
@junxie6
junxie6 / httpsproxy.go
Last active September 23, 2020 21:24 — forked from wwek/httpsproxy.go
https proxy in golang
// https://medium.com/@mlowicki/http-s-proxy-in-golang-in-less-than-100-lines-of-code-6a51c2f2c38c
// #!/usr/bin/env bash
// case `uname -s` in
// Linux*) sslConfig=/etc/ssl/openssl.cnf;;
// Darwin*) sslConfig=/System/Library/OpenSSL/openssl.cnf;;
// esac
// openssl req \
// -newkey rsa:2048 \
// -x509 \
@junxie6
junxie6 / net-test.go
Created September 15, 2020 16:02 — forked from vys/net-test.go
A simple client and server with lots of connections in GO. Testing GO's network connection handling.
package main
import (
"flag"
// "fmt"
"github.com/vys/go-humanize"
"io"
"log"
"net"
//"net/http"
@junxie6
junxie6 / channels.go
Created September 6, 2020 16:41 — forked from quasilyte/channels.go
Channel vs mutex vs atomic for synchronized counter
package benchmark
import (
"context"
"runtime"
"sync"
"sync/atomic"
"testing"
"time"
)