Gist with files I have used for managing Git repositories
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
use core::borrow::Borrow; | |
use core::cmp::Ordering; | |
use core::fmt; | |
use core::hash::{Hash, Hasher}; | |
use core::ops::Deref; | |
use std::borrow::Cow; | |
use self::BoxOrRef::{Borrowed, Owned}; | |
pub enum BoxOrRef<'a, T: ?Sized + 'a> { |
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
class BiMap { | |
#k_to_v = new Map(); | |
#v_to_k = new Map(); | |
set(key, value) { | |
if (this.#k_to_v.get(key) === value) return this; | |
this.deleteKey(key); | |
this.deleteValue(value); | |
this.#k_to_v.set(key, value); | |
this.#v_to_k.set(value, key); |
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
use core::cell::Cell; | |
use core::fmt::{Display, Formatter, Result}; | |
struct FormatDelimited<'a, T, I, F> | |
where | |
I: IntoIterator<Item = T>, | |
F: Fn(&mut Formatter<'_>, &T) -> Result, | |
{ | |
inner: Cell<Option<(I, F)>>, | |
sep: &'a str, |
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
use facet::{ | |
EnumType, Field, PointerType, Shape, StructKind, StructType, Type, UnionType, UserType, | |
}; | |
pub trait RecursiveShape<'shape> { | |
fn shape_by_path(&self, path: &[impl AsRef<str>]) -> Option<&Shape<'shape>>; | |
fn field_by_path(&self, path: &[impl AsRef<str>]) -> Option<&Field<'shape>>; | |
} |
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
My personal stance is that 1. all adjacent whitespace can be represented by a single token, 2. whitespace between expressions is significant, 3. whitespace adjacent to punctuation is parsed with the operator token, 4. no other whitespace is significant |
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
# Overrides to keep packages building after Rust 1.80.0. | |
# There is a regression with type inference that primarily affects | |
# the `time` crate, so for packages that use it, go back one version. | |
# <https://github.com/NixOS/nixpkgs/issues/332957> | |
pkgs: pkgs0: | |
let | |
rustVersion = "1.79.0"; | |
rustPlatform = pkgs.makeRustPlatform { | |
cargo = pkgs.rust-bin.stable.${rustVersion}.default; | |
rustc = pkgs.rust-bin.stable.${rustVersion}.default; |
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
eachNewer = lib.filterAttrs (name: updatedPackage: | |
let | |
verNixpkgs = pkgs0.${name}.version; | |
verOverride = updatedPackage.version; | |
in if lib.versionOlder verNixpkgs verOverride then | |
true | |
else | |
lib.warn '' | |
package `${name}` has an overlay but the version in Nixpkgs is newer | |
(${verNixpkgs} >= ${verOverride}) |
- Naming of overlay parameters, by scope
- Allow
mkShell
do the heavy lifting, usepackages
andinputsFrom
- Proper usage of
nixpkgs.lib.extend
using more overlays (TODO)- Also avoid
import
ing your own global functions everywhere, and registering functions inconfig
.
- Also avoid
- Use
nix-systems
andpkgsFor.${system}
NewerOlder