Skip to content

Instantly share code, notes, and snippets.

View bynect's full-sized avatar
🙄
Procrastinating

nect bynect

🙄
Procrastinating
  • Laniakea Supercluster
  • 02:15 (UTC +02:00)
View GitHub Profile
@bynect
bynect / bot.py
Last active April 29, 2024 12:58
Simple and effective example of bot and cogs made with discord.py (rewrite).
"""
This example bot is structured in multiple files and is made with the goal of showcasing commands, events and cogs.
Although this example is not intended as a complete bot, but as a reference aimed to give you a basic understanding for
creating your bot, feel free to use these examples and point out any issue.
+ These examples are made with educational purpose and there are plenty of docstrings and explanation about most of the code.
+ This example is made with Python 3.8.5 and Discord.py 1.4.0a (rewrite).
Documentation:
#!/bin/bash
# NOTE: This script exports only one uid
key_pattern=
remote_host=
remote_path=/var/www/html/.well-known/openpgpkey/hu/
for item in $(gpg --list-secret-keys --with-colons ${key_pattern:- } \
| awk -F: '($1 == "sec" && $2 == "u") { print $5}'); do
@bynect
bynect / invoke.c
Last active September 22, 2022 13:05
#define invoke(inst, meth, ...) (inst)->meth((inst), __VA_ARGS__)
@bynect
bynect / char-counter.cpp
Created June 28, 2022 17:17
Count (ascii) char occurrences in any utf8 file
#include <cctype>
#include <cstdint>
#include <fstream>
#include <iostream>
#include <locale>
#include <algorithm>
int main(int argc, char **argv)
{
std::locale::global(std::locale(""));
@bynect
bynect / build.sh
Last active June 20, 2022 16:09
Grid with 2d rotation example in SDL2
#!/bin/sh
set -xe
gcc -o main main.c -lSDL2
@bynect
bynect / svg.rs
Created August 29, 2021 13:13
Mini svg library in Rust
pub struct SVG {
text: String,
height: usize,
width: usize,
}
const INDENT: &str = " ";
const XMLNS: &str = "http://www.w3.org/2000/svg";
const XLINK: &str = "http://www.w3.org/1999/xlink";
@bynect
bynect / life_standalone.rs
Created August 24, 2021 16:08
Standalone Game of Life implementation in Rust. Uses libc's rand and srand functions for generating random grids.
use std::thread::sleep;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
#[derive(Debug, Copy, Clone)]
enum Cell {
Dead = 0,
Live = 1,
}
impl Cell {
@bynect
bynect / life.rs
Last active August 24, 2021 16:07
Game of Life implementation in Rust. Depends on the rand crate for generating random grids.
use std::thread::sleep;
use std::time::Duration;
// Add rand in the dependencies section of Cargo.toml
use rand::Rng;
#[derive(Debug, Copy, Clone)]
enum Cell {
Dead = 0,
Live = 1,
@bynect
bynect / memswap.h
Last active August 23, 2021 00:57
Memswap implementation in ISO C.
#ifndef MEMSWAP_H
#define MEMSWAP_H
static inline void
memswap(void *restrict aptr, void *restrict bptr, size_t len)
{
register unsigned char *a = aptr;
register unsigned char *b = bptr;
register unsigned char t;
@bynect
bynect / Makefile
Last active August 23, 2021 00:52
Very basic color gradient application made with OpenGL and glfw.
# Uncomment -DDYN_PROCS if dynamic loading of OpenGL function is preferable over static linking
CFLAGS=-O2 -Wall -Wextra #-DDYN_PROCS
LDFLAGS=-lglfw -lGL
gradient: gradient.o
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^
%.o: %.c
$(CC) -o $@ -c $(CFLAGS) $^