Skip to content

Instantly share code, notes, and snippets.

View Micrified's full-sized avatar
🇫🇷
Collating...

Micrified

🇫🇷
Collating...
  • Rotterdam, Nederlands
View GitHub Profile
@Micrified
Micrified / fail.go
Last active April 23, 2024 06:00
Yet another fail
package main
import "fmt"
type R interface {
A() string
B() string
}
type C interface {
R
Method(string) func(C)string
@Micrified
Micrified / sensor_reader.cpp
Created April 21, 2024 09:59
Safe sensor example
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <ratio>
#include <string>
#include <thread>
#include <vector>
#include <mutex>
// [ Written to C++11 standard ]
@Micrified
Micrified / syncmap.go
Last active March 10, 2024 18:26
Generic channel-synchronised map (Golang)
// Note: Use mutexes people
package main
import (
"fmt"
"sync"
)
// generic type: response
type re [T comparable, U any] struct {
@Micrified
Micrified / generic_struct_composition.go
Last active March 10, 2024 18:26
Generic struct composition
package main
import "fmt"
import "encoding/json"
import "bytes"
type AuthPost [T any] struct {
UserID string `json:"userid"`
SID string `json:"sid"`
Data T `json:"data"`
}
@Micrified
Micrified / comma-in-c.md
Created February 6, 2024 08:12
Comma operator in C if-statements

Comma Operator

In C and C++, the comma operator is a binary operator that:

  1. Evaluates the first operand, and discards the result
  2. Evalutes the second operand, and returns this value

So:

if (a,b) {
@Micrified
Micrified / parallel.go
Last active January 29, 2024 22:32
Parallel MD5 hasher (to be compared)
package main
// Continue here: https://go.dev/blog/pipelines
import (
"crypto/md5"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"sort"
"sync"
@Micrified
Micrified / square.go
Last active January 25, 2024 23:07
Go concurrency basic example
package main
import "fmt"
// Take a variadic list of integers, and launch a goroutine which will block trying to send them on channel 'out'
// Return this channel as a receive-only channel
func gen(ns ...int) <-chan int {
out := make(chan int) // Create a bidirectional channel
go func() {
for _, n := range ns {
@Micrified
Micrified / demo.cpp
Created December 29, 2023 20:01
Sensors
#include <iostream>
#include <memory>
#include <vector>
class Sensor
{
public:
enum Type
{
ALTIMITER = 0,
@Micrified
Micrified / enginesymbols.go
Created December 5, 2023 14:53
Day 3; Advent of Code
package main
import (
"fmt"
"bufio"
"os"
"strings"
"unicode"
)
@Micrified
Micrified / cubegames2.go
Created December 5, 2023 09:00
Advent of Code; Exercise 2; Part 2
package main
import (
"fmt"
"bufio"
"os"
"strings"
"math"
)