Skip to content

Instantly share code, notes, and snippets.

View MrDwarf7's full-sized avatar
🏠
Working from home

Blake B. MrDwarf7

🏠
Working from home
  • Australia
View GitHub Profile
import argparse
import subprocess
import sys
import os
def run_cmd(cmd, check=True):
"""
Helper to run a command using subprocess.
If check=True, raises an exception on nonzero return.
#!/usr/bin/env python3
"""
Automates creation of a baseline Btrfs layout on a given device/partition.
- Assumes the partition is already wiped or otherwise ready.
- Creates a Btrfs filesystem with a label.
- Creates subvolumes: @, @boot, @swap, @snapshots, @var, @home, @tmp
- Mounts @ at /mnt, then mounts the others to their respective subdirectories.
- NOTE: You must run this script with sudo (or as root).
@MrDwarf7
MrDwarf7 / CompactWSL.bat
Created November 18, 2024 01:53 — forked from Csqhi515/CompactWSL.bat
Script to help compact WSL and vhdx.
@echo off
net session >nul 2>&1
if %errorlevel% neq 0 (
echo Requesting administrative privileges...
powershell -Command "Start-Process '%~f0' -Verb RunAs"
exit /b
)
wsl sudo fstrim --all; echo "Exit status: $?";
{
// VIM/NEOVIM RELATED
"extensions.experimental.affinity": {
"asvetliakov.vscode-neovim": 1
},
"vscode-neovim.compositeTimeout": 200,
"vscode-neovim.compositeKeys": {
"jj": {
"command": "vscode-neovim.lua",
"args": [
@MrDwarf7
MrDwarf7 / .wezterm.lua
Created September 1, 2024 14:54 — forked from AntonC9018/.wezterm.lua
Wezterm config
local wezterm = require 'wezterm'
local act = wezterm.action
local config = wezterm.config_builder()
config.use_dead_keys = false
-- https://github.com/wez/wezterm/discussions/5102
config.enable_kitty_keyboard = true
config.allow_win32_input_mode = false
#!/bin/bash
clog --setversion v$(toml get Cargo.toml package.version |sed 's/"//g' | rg '\d+\.\d+\.\d+') \
&& git add CHANGELOG.md && git commit -m "chore: add changelog for pre release"
#https://github.com/zitsen/xlsx2csv.rs/blob/e557aeb039fb1be3b2fa8f375441bcf95dead605/clog.sh#L1
@MrDwarf7
MrDwarf7 / !README.md
Created July 25, 2024 07:31 — forked from mmozeiko/!README.md
Download MSVC compiler/linker & Windows SDK without installing full Visual Studio

This downloads standalone MSVC compiler, linker & other tools, also headers/libraries from Windows SDK into portable folder, without installing Visual Studio. Has bare minimum components - no UWP/Store/WindowsRT stuff, just files & tools for native desktop app development.

Run py.exe portable-msvc.py and it will download output into msvc folder. By default it will download latest available MSVC & Windows SDK - currently v14.40.33807 and v10.0.26100.0.

You can list available versions with py.exe portable-msvc.py --show-versions and then pass versions you want with --msvc-version and --sdk-version arguments.

To use cl.exe/link.exe first run setup_TARGET.bat - after that PATH/INCLUDE/LIB env variables will be updated to use all the tools as usual. You can also use clang-cl.exe with these includes & libraries.

To use clang-cl.exe without running setup.bat, pass extra /winsysroot msvc argument (msvc is folder name where output is stored).

#[test]
// #[ignore]
fn a_palindrome() {
let input = "racecar";
let output = reverse(input);
let expected = "racecar";
assert_eq!(output, expected);
}
#[test]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct ConfigSqlFiles {
files: Option<Vec<Option<PathBuf>>>,
}
impl ConfigSqlFiles {
pub fn get_files(&self) -> &Vec<Option<PathBuf>> {
self.files.as_ref().unwrap()
}
}
@MrDwarf7
MrDwarf7 / jsonp.js
Created March 2, 2024 03:03 — forked from gf3/jsonp.js
Simple JSONP in vanilla JS
/**
* loadJSONP( url, hollaback [, context] ) -> Null
* - url (String): URL to data resource.
* - hollaback (Function): Function to call when data is successfully loaded,
* it receives one argument: the data.
* - context (Object): Context to invoke the hollaback function in.
*
* Load external data through a JSONP interface.
*
* ### Examples