Skip to content

Instantly share code, notes, and snippets.

@Nejat
Nejat / winget-updates.nu
Last active April 6, 2024 04:44
Lists and optionally upgrades available WinGet updates. Skips Unknown versions or anything in the skip list
# winget-updates.nu
# GitHub Gists
# this script - https://gist.github.com/Nejat/06c275749b7931857bb4c7604a026877
# example skip config - https://gist.github.com/Nejat/5a41fe09bb27c1bbcf345fb1dea8a234
# powersheel version - https://gist.github.com/Nejat/6cb42f098320cb2fcb57a4e1728ca29e
# output formatting constants
const err_color: string = 'light_red'
const fail_color: string = 'red'
@Nejat
Nejat / pre-commit-rust
Created December 4, 2022 09:57
git pre-commit hook for rust projects
#!/bin/sh
set -eu
# if ! cargo fmt -- --check
# then
# echo "check/fix fmt issues ..."
# exit -1
# fi
@Nejat
Nejat / width.rs
Created May 22, 2022 19:38
calculate the max debug/display width of items in an iterator
use std::fmt::{Debug, Display, Write};
use std::ops::Deref;
/// The output width from a write statement
#[derive(Default, Eq, PartialEq, Ord, PartialOrd)]
struct Width(usize);
impl Width {
/// reset the stored width
fn reset(&mut self) {
@Nejat
Nejat / wngt-cfg
Last active September 22, 2022 08:27
Unity # use unity hub to manage versions of unitywinget
Citrix Workspace # need the installed version
Visual Studio Community* # use visual studio installer
PowerToys (Preview) # does not update correctly
Microsoft .NET SDK # does not update correctly
Microsoft Visual C++ # use visual studio installer
Windows Software Development Kit # use visual studio installer
JetBrains # use jetbrains toolbox
@Nejat
Nejat / msys2-setup.ps1
Last active October 16, 2021 01:36
installs MSys2 or refreshes an existing installation using winget; updates pacman, and optionally executes additional bash setup commands
param (
# provide a list of addition bash setup commands to invoke
[string] $additional = "msys2-additional-setup",
# true teardown existing installations, false to stop if installation exists
[switch] $refresh = $false
)
# constant defining MSys2 winget package name
[string] $package = "MSys2"
# checks to see if an installaiton already exists
@Nejat
Nejat / msys2-additional-setup
Last active July 27, 2021 19:07
additional bash setup commands to use when setting up MSys2 with msys2-setup.ps1
pacman -S --needed base-devel mingw-w64-x86_64-toolchain | Development Toolchain
pacman -S --needed mingw-w64-x86_64-meson | Meson
pacman -S --needed mingw-w64-x86_64-vulkan-devel | Vulkan Development Tools
pacman -S --needed mingw-w64-x86_64-gtk3 | GTK3 Development Tools
pacman -S --needed mingw-w64-x86_64-gtk4 | GTK4 Development Tools
pacman -S --needed mingw-w64-x86_64-glade | GTK GLade Interface Designer
@Nejat
Nejat / winget-updates.ps1
Last active March 14, 2023 11:48
Lists and optionally upgrades available updates. Skips Unknown versions or anything in the skip list
param(
# provide a configuration file to define package handling
[string] $skipFile = "wngt-cfg",
# true to upgrade eligible packages, false dry run
[switch] $upgrade = $false
)
# adjust buffer size of output, really don't know if this helps ¯\_(ツ)_/¯
if ($Host -and $Host.UI -and $Host.UI.RawUI) {
$rawUI = $Host.UI.RawUI
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
// in cargo.toml
// rand = "0.7"
// parking_lot = "0.11"
// crossbeam-channel = "0.5"
use std::{thread::{JoinHandle, sleep, spawn}, time::Duration};
use crossbeam_channel::{Sender, unbounded};
use rand::{Rng, thread_rng};
// in cargo.toml
// rand = "0.7"
// parking_lot = "0.11"
// crossbeam-channel = "0.5"
use std::{thread::{sleep, spawn}, time::Duration};
use crossbeam_channel::{RecvTimeoutError, Sender, unbounded};
use rand::{Rng, thread_rng};