Skip to content

Instantly share code, notes, and snippets.

View DennisPing's full-sized avatar

Dennis Ping DennisPing

View GitHub Profile
@DennisPing
DennisPing / copying-stuff-to-array.go
Created September 21, 2022 06:38
Compiler magic?
func AppendDataNaive(packet1 []byte, packet2 []byte) uint16 {
// Do some initial work done with packet1 and packet2...
// Don't set any capacity, let Go auto-resize
data := make([]byte, 0)
data = append(data, packet1...)
data = append(data, packet2...)
// Do some calculations with 'data'
return calculatedValue
}
@DennisPing
DennisPing / console.log
Created February 18, 2022 02:45
Lab 2: Unable to compile (make) the baseline code
~/Doc/CS56/lab2-DennisPing main ❯ make
+ cc cmdparse.c
cmdparse.c: In function ‘cmd_line_parse’:
cmdparse.c:387:40: error: implicit conversion from ‘tokentype_t’ to ‘controlop_t’ [-Werror=enum-conversion]
387 | cmd->controlop = token.type;
| ^
cmdparse.c:392:40: error: implicit conversion from ‘tokentype_t’ to ‘controlop_t’ [-Werror=enum-conversion]
392 | cmd->controlop = token.type;
| ^
cc1: all warnings being treated as errors
@DennisPing
DennisPing / fast.cpp
Last active December 9, 2021 17:44
C++ std async vs regular loops performance
// Tutorial by The Cherno on Youtube
// https://youtu.be/5HWCsmE9DrE
// Compile using
// g++ -std=c++17 fast.cpp -o fast
#include <vector>
#include <chrono>
#include <thread>
#include <future>