Skip to content

Instantly share code, notes, and snippets.

@xtqqczze
xtqqczze / git-purge-remote.sh
Last active October 1, 2025 21:33
Delete all remote Git branches
#!/bin/sh
# git-purge-remote.sh
# Deletes all remote branches for a given remote, except HEAD and main.
# Name of the remote to purge. Change if needed.
REMOTE_NAME=origin
# List all remote branches for the given remote, excluding HEAD and main.
# Pipe the branch names to git push to delete them
# xargs -r prevents git push from running if there are no branches
@xtqqczze
xtqqczze / ensure_final_newline.py
Created September 3, 2025 10:24
This file was generated by ChatGPT on 2025-09-03
import os
import pathlib
import sys
def ensure_final_newline(root_dir=".", extension=".cs"):
"""
Ensures that all files with the given extension under root_dir
end with exactly one newline.
"""
if not extension.startswith("."):
@xtqqczze
xtqqczze / ensure_resx_newlines.py
Created September 3, 2025 09:54
This file was generated by ChatGPT on 2025-09-03
import os
import pathlib
def ensure_final_newline_in_resx(root_dir="."):
"""
Ensures that all .resx files under root_dir end with exactly one newline.
"""
root = pathlib.Path(root_dir)
resx_files = list(root.rglob("*.resx"))
@xtqqczze
xtqqczze / find_unreferenced_cs.py
Last active August 28, 2025 16:09
This file was generated by ChatGPT on 2025-08-28
#!/usr/bin/env python3
"""
find_unreferenced_cs.py
Finds all *.cs files under a given directory and lists the ones
whose **filename** is not mentioned in ANY *.csproj or *.projitems in the repo.
Run from repo root:
python3 find_unreferenced_cs.py --dir src/libraries/Common/src/Interop
using System;
using System.Collections;
using System.Linq;
using BenchmarkDotNet.Attributes;
[MemoryDiagnoser]
public class Benchmarks
{
private readonly IDictionary _dict = Enumerable.Range(0, 10000).ToDictionary(i => i.ToString(), i => string.Empty);
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Collections.Generic;
using System.Linq;
[MemoryDiagnoser]
[DisassemblyDiagnoser]
public class Program
{
private List<int> list = Enumerable.Repeat(10, 10).ToList();
@xtqqczze
xtqqczze / gist:b3a1c299bf0e7562ad2938dc7f036967
Created January 22, 2021 23:32
BenchmarkStringContains.Dissambly
## .NET Core 5.0.2 (CoreCLR 5.0.220.61120, CoreFX 5.0.220.61120), X64 RyuJIT
```assembly
; Program.ContainsStringLocal()
mov rdx,197EA839518
mov rdx,[rdx]
mov rcx,[rcx+8]
cmp [rcx],ecx
jmp near ptr System.String.Contains(System.String)
; Total bytes of code 24
```
@xtqqczze
xtqqczze / gist:6c282c3519258c2ad250c861a37f2353
Created January 22, 2021 23:25
BenchmarkStringContains
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
[MemoryDiagnoser]
[DisassemblyDiagnoser]
public class Program
{
private string str = "whatever";
private string find = "a";
@xtqqczze
xtqqczze / user-profile.psm1
Created December 6, 2018 13:43
PowerShell functions to create a new user profile
<#
.Synopsis
Rough PS functions to create new user profiles
.DESCRIPTION
Call the Create-NewProfile function directly to create a new profile
.EXAMPLE
Create-NewProfile -Username 'testUser1' -Password 'testUser1'
.NOTES
Created by: Josh Rickard (@MS_dministrator) and Thom Schumacher (@driberif)