Skip to content

Instantly share code, notes, and snippets.

View paul-hansen's full-sized avatar

Paul Hansen paul-hansen

View GitHub Profile
@paul-hansen
paul-hansen / leptos_0.6-0.7_migration_helpers.md
Last active January 16, 2025 23:08
Leptos 0.6-0.7 Migration Helpers

Leptos 0.6-0.7 Migration Helpers

List of regex substitutions to help migrate a Leptos app from Leptos 0.6 to 0.7

Using with Vim/Neovim

The provided example regex for each step can be run in Vim/Neovim by using :% followed by the regex to apply to the current buffer. You can also use :cfdo % instead to apply to all the files in your quickfix list. So to put this all together, use something like the telescope file finder to find all .rs files, press ctrl+q to send them to the quickfix list, then :cfdo %s/create_resource(/Resource::new(/g and that will apply the create_resource rename.

@paul-hansen
paul-hansen / init.lua
Last active October 5, 2024 21:41
Neovim tailwindcss lspconfig setup for Rust + Leptos using classRegex
require 'lspconfig'.tailwindcss.setup {
filetypes = { "rust_with_rstml", "rstml", "rust" },
init_options = {
userLanguages = {
rust = "html",
}
},
settings = {
tailwindCSS = {
classAttributes = { "class", "className", "class:list", "classList", "ngClass" },

If you are experiencing Bevy's renderer freezing until you resize the window and are on KDE plasma with wayland, this workaround might help you.

It's normally accompanied by this warning [source]:

Couldn't get swap chain texture. This often happens with the NVIDIA drivers on Linux. It can be safely ignored.

Setup I was experiencing this on:

KDE plasma: 6.1.2
Nvidia driver: 555.58.02
Kernel: 6.9.9-arch1-1

This guide shows you how to configure KDE Plasma's window rules to position a window matching a criteria whenever it opens and prevent the window from gaining focus. Specifically I use this in combination with automatically rebuilding and launching my Bevy game whenever a file changes using cargo watch -i assets -- cargo run --features=bevy/dynamic_linking --features=bevy/file_watcher. This allows me to see changes as I'm writing my Bevy App but not loose focus from my editor.

  1. Set the "Window.name" value in your bevy app to something specific to your app.
    fn main() {
        App::new()
            .add_plugins((
                DefaultPlugins.set(WindowPlugin {
                    primary_window: Some(Window {
@paul-hansen
paul-hansen / bevy_0_11_ast-grep.md
Last active September 26, 2023 22:27
Bevy 0.11 migration with ast-grep

Bevy 0.11 migration with ast-grep

Uses ast-grep to apply some parts of bevy 0.10 to 0.11 migration that can be automated.

You should review any changes this makes.

cargo install ast-grep
sg -p 'Clicked' --rewrite 'Pressed' -U
sg -p 'LAlt' --rewrite 'AltLeft' -U
@paul-hansen
paul-hansen / main.rs
Created December 2, 2022 22:17
Hangman rust game written by ChatGPT
/// Everthing below this comment block was generated by ChatGPT from the prompt:
/// "write a hangman game in the rust language without comments"
/// (with comments it was too long and cut off the end)
use std::collections::HashSet;
use std::io;
const MAX_GUESSES: i32 = 6;
fn main() {
println!("Enter a word for the other player to guess: ");
@paul-hansen
paul-hansen / UpArrowLongPressAsShift.ahk
Last active July 18, 2021 19:17
AutoHotKey script to treat a long press of the up arrow key as shift. Useful for laptops like the Razer Blade stealth 13 since the up arrow is where shift should be.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Up::
; Wait for time to see if it is still pressed
KeyWait, Up, T0.07
if (ErrorLevel){
; Still being pressed, treat as shift
Send {Shift Down}