Skip to content

Instantly share code, notes, and snippets.

@BlueDrink9
BlueDrink9 / teardrop.scad
Last active January 7, 2024 05:47
Basic teardrop shape in openscad
/* Creates a flat 2D teardrop on the XY plane,
* where no angle in the positive y direction is greater than 45º.
* */
module teardrop2d(radius){
// Find tangents on the circle at 45 degrees
// Radius is triangle hypotenuse
function tangent_point(circle_r, angle) = [
circle_r * cos(angle),
circle_r * sin(angle),
];
@BlueDrink9
BlueDrink9 / lazy.nvim adapter for vim-plug.md
Last active February 29, 2024 16:27
Share your vim-plug plugins with your lazy.nvim neovim setup, with minimal performance loss

lazy.nvim adapter for vim-plug

This is a drop-in adapter layer for vim-plug and lazy.nvim, allowing you to have a core set of vim plugins, configured with Plug, which will also be loaded using lazy.nvim instead whenever you use neovim (alongside any additional set of lazy.nvim plugins you have configured.)

It works by adding a new command Plugin as a drop-in Plug replacement. That calls a function that sets up lazy.nvim specs for the equivalent Plug args, and stores them in a variable that you can then add to your lazy spec.

@BlueDrink9
BlueDrink9 / Always reboot to Windows instead of Linux during a Windows update (systemd-boot).md
Last active March 13, 2021 03:35
Always reboot to Windows instead of Linux during a Windows update (systemd-boot)

Motivation

Say you dual boot Windows and Linux, and use the simple and light-weight systemd-boot to switch OS. Say you boot to Linux by default. However, this causes headaches when Windows updates and needs to restart as part of the process, especially if it has to do so multiple times (for example major feature updates).

You could change the default right before you boot

Automatically set Windows as next boot when restarting as part of an Update

Create a script %windir%\System32\update\run\precommit.cmd with the following contents:

@BlueDrink9
BlueDrink9 / vim-jupytext-foldexpr
Last active April 10, 2020 07:19
Fold percent-style cells (like used by jupytext) in vim
function GetJupytextFold(linenum)
if getline(a:linenum) =~ "^#\\s%%"
" start fold
return ">1"
elseif getline(a:linenum + 1) =~ "^#\\s%%"
return "<1"
else
return "-1"
endif
@BlueDrink9
BlueDrink9 / WSLtty set environment variable on startup
Created October 9, 2019 00:27
WSLtty set environment variable on startup as a mintty arg
`mintty_args=--WSL="Ubuntu" --configdir="%APPDATA%\wsltty\dropdown_config" -"~" /bin/sh -c "export VARIABLE='value' && $SHELL -il"`
@BlueDrink9
BlueDrink9 / Fix arch EFI boot from windows.md
Last active February 1, 2020 07:14
Fix arch EFI boot from windows after a windows update messes with the config. Also: how to access efi partition.
  1. Open elevated command prompt.

run mountvol b: /s

Change to efi partition with b:

cd loader\entries

edit arch.conf to make any adjustments, like changing the partition.

@BlueDrink9
BlueDrink9 / Pass environment variables through to ssh and tmux each time you log in
Last active August 26, 2022 15:34
Pass environment variables through to ssh/tmux each time you log in
This is a working solution I have found to the problem of updating values like whether you should use a powerline/nerd patched font,
truecolors or what escape codes to use when sshed into a server that knows no specifics about your current terminal.
SSH by default doesn't pass many variables through, with some caveats.
Tmux, also, will not refresh any variables from the underlying shell.
The way it works initally is by aliasing ssh to a function that first runs a command to export the specified options to the ssh shell,
then runs the user's default shell.
Tmux adds an extra layer to this. By default, it will integrate the shell variables on the **first run only**.
Once it's running, and you create new sessions or reattach from a different terminal, nothing changes.
@BlueDrink9
BlueDrink9 / Autohotkey in Onenote - Up and Down.md
Last active October 27, 2020 06:08
Send up and down in Onenote with Autohotkey

Problem: Autohotkey cannot send up and down in MS Onenote.

ctrl (^) + up and down work, as does sending something like {end}{right}{end}. This is not quite the same functionality though.

Solution: Don't use AHK.

AutoIT, a similar language, for some reason can send up and down to onenote fine. The workaround used for projects like vim for onenote uses precompiled autoit exes, which do exactly this. They are fast, and work well.