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
//! Higher-kinded types in Rust | |
//! | |
//! Functor, Applicative, and Monad traits | |
//! | |
//! Example implementations for custom Maybe type | |
// -- Trait Definitions -- // | |
/// A constructor for a type of a higher kind with one type parameter | |
pub trait TypeClass { |
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 <iostream> | |
#include <string> | |
#include <string_view> | |
#include <tuple> | |
#include <typeinfo> | |
#include <cstdio> | |
#include <vector> | |
std::vector<size_t> find_placeholders(const std::string_view& fmt) { | |
std::vector<size_t> positions; |
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
#[derive(Debug)] | |
struct Pipe<T>(T); | |
impl<T> std::ops::Deref for Pipe<T> { | |
type Target = T; | |
fn deref(&self) -> &Self::Target { | |
&self.0 | |
} | |
} |
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
// --- examples --- // | |
// happy path | |
const Priority = Enum("Low", "Normal", "High"); | |
// ^? | |
type Priority = Enum<typeof Priority>; | |
// ^? | |
// invalid key starting with number | |
const InvalidPriority1 = Enum("1Low", "Normal", "High"); |
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
# train_grpo.py | |
import re | |
import torch | |
from datasets import load_dataset, Dataset | |
from transformers import AutoTokenizer, AutoModelForCausalLM | |
from peft import LoraConfig | |
from trl import GRPOConfig, GRPOTrainer | |
# Load and prep dataset |
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
/* | |
[dependencies] | |
*/ | |
mod sealed { | |
pub trait IsType<T: ?Sized> {} | |
impl<T: ?Sized> IsType<T> for T {} | |
} |
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
type Op = '<<' | '&' | '|'; | |
const Gift = { | |
Coal: '0', | |
Train: '1 << 0', | |
Bicycle: '1 << 1', | |
SuccessorToTheNintendoSwitch: '1 << 2', | |
TikTokPremium: '1 << 3', | |
Vape: '1 << 4', | |
Traditional: 'Train | Bicycle', |
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
import type { Expect, Equal, IsAny, IsUnknown } from "type-testing"; | |
import { Solution } from "./solution"; | |
// biome-ignore lint/suspicious/noExplicitAny: <explanation> | |
type AnyArray = any[]; | |
type PartialApplicationHelper<T extends AnyArray, R> = <A extends Partial<T>>( | |
...args: A | |
) => A extends AnyArray | |
? A["length"] extends T["length"] |
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
interface Service { | |
ratio: number; | |
name: string; | |
} | |
function assignNumWorkers(services: Service[], maxTotalWorkers: number): Map<string, number> { | |
// sub 1 for the orchestrator | |
const availableWorkers = maxTotalWorkers - 1; | |
// calc total ratio sum |
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
/** | |
* Syslog Facility codes as defined in RFC 5424 | |
*/ | |
enum SyslogFacility { | |
KERN = 0, // kernel messages | |
USER = 1, // user-level messages | |
MAIL = 2, // mail system | |
DAEMON = 3, // system daemons | |
AUTH = 4, // security/authorization messages | |
SYSLOG = 5, // messages generated internally by syslogd |
NewerOlder