Skip to content

Instantly share code, notes, and snippets.

View netgusto's full-sized avatar
:bowtie:

netgusto netgusto

:bowtie:
View GitHub Profile
@hazkaz
hazkaz / zigzag.js
Created January 18, 2018 17:23
zigzag PID bot
const { vector, comm } = require("bytearena-sdk");
const Vector2 = vector.Vector2;
const agent = comm.connect();
let count = 1
const countLimit = 55
let countDirection = 1
let first = true
let angle = 0
agent.on("perception", perception => {
@munificent
munificent / generate.c
Last active January 27, 2025 18:14
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@jimmychu0807
jimmychu0807 / string-conversion.rs
Created November 21, 2019 10:20
Conversion between String, str, Vec<u8>, Vec<char> in Rust
use std::str;
fn main() {
// -- FROM: vec of chars --
let src1: Vec<char> = vec!['j','{','"','i','m','m','y','"','}'];
// to String
let string1: String = src1.iter().collect::<String>();
// to str
let str1: &str = &src1.iter().collect::<String>();
// to vec of byte
@netgusto
netgusto / siginfo.go
Last active November 11, 2022 10:02
SIGINFO (Ctrl+t) to dump live metrics in go
// Send SIGINFO (Ctrl+t on the shell, or kill -info <pid>)
// To dump live metrics
go func() {
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINFO)
for range sigs {
duration := time.Since(start)
// obviously adapt this next line to your need :)
logger.Info(fmt.Sprintf("Processed %d jobs in %s; Throughput=%.4f/s\n", nbprocessed, duration.String(), float64(nbprocessed)/duration.Seconds()))