Skip to content

Instantly share code, notes, and snippets.

View hebl's full-sized avatar

HE Boliang hebl

View GitHub Profile
@leiless
leiless / uv_pipe_ipc_echo.c
Created July 11, 2020 07:55
libuv pipe IPC echo client/server example
/*
* Created Jul 4, 2020.
*/
#include <unistd.h>
#include <uv.h>
#include "test.h"
#include "utils.h"
#include "assertf.h"
package main
import (
"fmt"
"math/rand"
"sync"
"time"
)
type DataEvent struct {
@trevershick
trevershick / CMakeLists.txt
Last active November 21, 2023 06:54
Simple client and server using libuv and unix domain sockets...
set(CMAKE_BUILD_TYPE Debug)
cmake_minimum_required(VERSION 2.8.12)
project(libuv1)
add_definitions("-std=c++11")
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
add_executable(server server.cpp)
@eteq
eteq / parallax_GaiaDR2.ipynb
Last active June 15, 2021 00:37
An demonstration of parallax using stars near the sun from the Gaia mission, astropy, astroquery, and matplotlib.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rushilgupta
rushilgupta / GoConcurrency.md
Last active May 14, 2024 06:30
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@xxlukas42
xxlukas42 / esp32_internal_hall.ino
Last active April 21, 2024 04:16
Arduino source code for ESP32 internal temperature sensor and hall sensor
void setup() {
Serial.begin(115200);
}
void loop() {
int measurement = 0;
measurement = hallRead();
net.ipv4.ip_forward=1
net.ipv6.conf.default.forwarding=1
net.ipv6.conf.6rdtun.forwarding=1
net.ipv6.conf.all.forwarding=1
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thealexcons
thealexcons / jwt_golang_example.go
Last active April 16, 2023 03:04
JSON Web Tokens in Go
package main
import (
"io/ioutil"
"log"
"strings"
"net/http"
"encoding/json"
"fmt"
"time"
@xlab
xlab / bytes_split.go
Last active April 4, 2022 17:21
Golang split byte slice in chunks sized by limit
func split(buf []byte, lim int) [][]byte {
var chunk []byte
chunks := make([][]byte, 0, len(buf)/lim+1)
for len(buf) >= lim {
chunk, buf = buf[:lim], buf[lim:]
chunks = append(chunks, chunk)
}
if len(buf) > 0 {
chunks = append(chunks, buf[:len(buf)])
}