Skip to content

Instantly share code, notes, and snippets.

View cj1128's full-sized avatar

CJ cj1128

View GitHub Profile
package main
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"strings"
)
@cj1128
cj1128 / simple-tcp-server.c
Last active May 21, 2022 10:53
A simple tcp server written in C
#include <stdio.h>
#include <netinet/in.h>
#include <stdlib.h>
#include <sys/socket.h>
#define PORT 8080
#define SA struct sockaddr
int main()
{
int sockfd, connfd, len;
function Mue(opts) {
opts.data = opts.data || {}
opts.computed = opts.computed || {}
opts.watch = opts.watch || {}
const self = this
const watchers = {}
function observe(key, fn) {
@cj1128
cj1128 / core-value-encode.js
Created May 22, 2018 13:55
Encode string use core value word
const chars = [
"富强",
"民主",
"文明",
"和谐",
"爱国",
"敬业",
"诚信",
"友善",
"自由",
@cj1128
cj1128 / a-simple-promise.js
Created May 18, 2018 02:16
A simple promise implementation
// pending
// fulfilled
// rejected
class MyPromise {
constructor(executor) {
this.$state = "pending"
this.$res = null
this.$chain = []