This file contains hidden or 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
#[macro_export] | |
macro_rules! async_callback { | |
// Version without event parameter | |
([$($var:ident),* $(,)?] $body:expr) => { | |
{ | |
$(let $var = $var.clone();)* | |
Callback::from(move |_| { | |
$(let $var = $var.clone();)* | |
wasm_bindgen_futures::spawn_local(async move { | |
$body |
This file contains hidden or 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
#!/bin/bash | |
# Get all tracked files in git | |
files=$(git ls-files) | |
# Create a temporary file to store the output | |
temp_file=$(mktemp) | |
# Process each file | |
for file in $files; do |
This file contains hidden or 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 <stdbool.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <time.h> | |
#include <unistd.h> | |
typedef uint32_t u32; | |
typedef uint8_t u8; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) |
NewerOlder