Skip to content

Instantly share code, notes, and snippets.

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 Sep 25, 2021 — forked from lpereira/coro.c
Simple coroutine implementation in C
View coro.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 Sep 8, 2021 — forked from zapstar/openssl_2way_auth.sh
Steps to create CA, server and client keys + certificates for SSL 2-way authentication
View openssl_2way_auth.sh
# 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 Jun 28, 2021 — forked from xjdrew/client.go
golang tls client and server, require and verify certificate in double direction
View client.go
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io"
"io/ioutil"
"log"
"os"
@junxie6
junxie6 / array.c
Created May 11, 2021 — forked from FurryHead/array.c
Dynamic array and map in C.
View array.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 — forked from matugm/array.c
dynamic arrays in c
View array.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;
View gist:ba728aeb19fb226bb09094289fa48ef4
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 Sep 23, 2020 — forked from wwek/httpsproxy.go
https proxy in golang
View httpsproxy.go
// 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 Sep 15, 2020 — forked from vys/net-test.go
A simple client and server with lots of connections in GO. Testing GO's network connection handling.
View net-test.go
package main
import (
"flag"
// "fmt"
"github.com/vys/go-humanize"
"io"
"log"
"net"
//"net/http"
@junxie6
junxie6 / channels.go
Created Sep 6, 2020 — forked from quasilyte/channels.go
Channel vs mutex vs atomic for synchronized counter
View channels.go
package benchmark
import (
"context"
"runtime"
"sync"
"sync/atomic"
"testing"
"time"
)