Skip to content

Instantly share code, notes, and snippets.

View SeedyROM's full-sized avatar
🚂
Coding Time

Zack Kollar SeedyROM

🚂
Coding Time
View GitHub Profile
@SeedyROM
SeedyROM / main.cpp
Created January 29, 2024 04:55
`std::variant` polymorphism example
#include <string>
#include <iostream>
#include <variant>
#include <vector>
struct Vector2 {
float x, y;
};
struct Player {
@SeedyROM
SeedyROM / example.rs
Created January 13, 2023 06:38
Type Erased Blanket Assiocated Types
trait A {}
trait B {
type X: A;
fn test(&self) -> &Self::X;
}
trait C {
fn test(&self) -> &dyn A;
}
impl A for i32 {}
@SeedyROM
SeedyROM / stringifed_any.rs
Last active March 19, 2022 09:37
Rust Envy nested serialization help
//
// Source from: https://github.com/softprops/envy/issues/26#issuecomment-822728576
//
use std::{
fmt::{self, Display},
marker::PhantomData,
str::FromStr,
};
@SeedyROM
SeedyROM / Lib.hs
Created March 11, 2022 23:32
WebSocket Pipes
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Lib where
import Control.Concurrent (forkIO)
import Control.Monad (Monad, forever, unless)
import Control.Monad.Trans (liftIO)
import Data.Aeson (FromJSON (parseJSON), KeyValue ((.=)), ToJSON (toJSON), decode, object, withObject, (.:))
@SeedyROM
SeedyROM / Cargo.toml
Created February 14, 2022 10:23
Rust Setup
[package]
name = "my-package"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
color-eyre = "0.6.0"
tracing = "0.1.30"
@SeedyROM
SeedyROM / test.c
Last active December 20, 2021 06:42
Idempotent ASCII Lowercase/Uppercase char with C
#include <assert.h>
int main(int argc, char *argv[])
{
unsigned char cu = 'X';
unsigned char cl = 'x';
// Idempotent lowercase
assert(cl == (cu | 0x20));
assert(cl == (cl | 0x20));
@SeedyROM
SeedyROM / Makefile
Last active December 17, 2021 04:58
C Makefile Template (OOS Build)
TARGET_EXEC ?= a.out
# Where to build our resources
BUILD_DIR ?= ./build
# Where our code lives
SRC_DIRS ?= ./src
# Makefile magic to build object files and deps for our sources
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
// -------------------------------------------------------------------------------------------------------------------
import BigNumber from 'bignumber.js';
import { logger, Postgres } from 'node-common';
import { BlockRaw } from '../../types';
import { isContinousSequence, normalizeBlockchainId, normalizeTimestamp } from '../../helpers';
import groupBy from 'lodash/groupBy';
import uniqBy from 'lodash/uniqBy';
import { createKafkaOptions } from '../baseConsumer';
@SeedyROM
SeedyROM / launch.json
Created October 1, 2020 08:05
BackpackJS and VSCode Debugging Integration
{
"version": "0.2.0",
"configurations": [
{
"type": "pwa-node", // This is important otherwise the paths and arguments all don't work
"request": "launch",
"name": "Debug {{YOUR_SERVICE}}",
"program": "${workspaceFolder}/node_modules/backpack-core/bin/backpack",
"args": ["dev", "|", "pino-pretty", "-c"], // Last two argument are optional, I use pino at work for logging
// Also pipe our logs into pino-pretty -c for nicer outputs
@SeedyROM
SeedyROM / launch.json
Last active October 1, 2020 08:22
VSCode debugging with ts-node
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "pwa-node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],
"args": ["src/{{YOUR_ENTRYPOINT}}.ts"],