This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <variant> | |
#include <vector> | |
struct Vector2 { | |
float x, y; | |
}; | |
struct Player { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait A {} | |
trait B { | |
type X: A; | |
fn test(&self) -> &Self::X; | |
} | |
trait C { | |
fn test(&self) -> &dyn A; | |
} | |
impl A for i32 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Source from: https://github.com/softprops/envy/issues/26#issuecomment-822728576 | |
// | |
use std::{ | |
fmt::{self, Display}, | |
marker::PhantomData, | |
str::FromStr, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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, (.:)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ------------------------------------------------------------------------------------------------------------------- | |
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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"], |
NewerOlder