Skip to content

Instantly share code, notes, and snippets.

View cmbaughman's full-sized avatar
🎯
Focusing

Chris Baughman cmbaughman

🎯
Focusing
View GitHub Profile
@cmbaughman
cmbaughman / performance_cte.md
Created August 19, 2025 13:51
Fixing SQL Query Performance With CTEs

Fixing SQL Query Performance With CTEs

Original query. Execution time: 127 seconds. +150 million rows.

SELECT
    c.customer_id,
    c.segment,
    SUM(t.amount) AS total_spent
FROM customers c
@cmbaughman
cmbaughman / minimalistcool_css_stuff.md
Created June 13, 2025 14:08
Minimalist CSS Only Stuff

Cool CSS Only Stuff

CSS Only Modals

<a href="#modal">Open Modal</a>

<div id="modal" class="modal">
  <a href="#" class="close">×</a>
  <p>This is a CSS-only modal window!</p>
@cmbaughman
cmbaughman / useful.js
Created June 11, 2025 13:27
Cool Javascripts to reuse
// Download file
export function downloadFile(url, filename) {
const a = document.createElement("a");
a.href = url;
a.download = filename;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
}
// Example: downloadFile("/resume.pdf", "MyResume.pdf");
@cmbaughman
cmbaughman / move.bat
Created March 14, 2025 13:32
Simple bat file calling powershell to move the mouse every 5 minutes.
@echo off
setlocal
:loop
powershell -command "[void][System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point((Get-Random -Minimum 0 -Maximum 1920), (Get-Random -Minimum 0 -Maximum 1080))"
timeout /t 300 /nobreak >nul
goto loop
endlocal
@cmbaughman
cmbaughman / wild.js
Created February 6, 2025 18:26
Wild Javascript APIs
// Get connection speed
if (navigator.connection) {
const downlink = navigator.connection.downlink;
console.log(`Current download speed: ${downlink} Mbps`);
}
else {
console.log("Network Information API not supported");
}
// Mobile device vibrate
@cmbaughman
cmbaughman / .editorconfig
Created May 29, 2024 19:14
Editor Config
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
quote_type = single
### Frontend files
# Windows God Mode
Create a folder anywhere you want a shortcut to
every setting imaginable called `GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}`
That's it. I got this from Twitter or something.
@cmbaughman
cmbaughman / ubuntu-docker.md
Last active May 3, 2024 14:56
Install Docker on Ubuntu and using Windows 11

Installing Docker on Ubuntu

Setup

  1. Make sure you have gnome-terminal installed:
sudo apt install gnome-terminal
  1. Get rid of older versions if you have them:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
@cmbaughman
cmbaughman / find_date.md
Created February 1, 2024 15:39
Linux copy files based on date

To copy some files from one directory to another can be done kinda nicely with the find command.

  1. First define the start date: touch --date "2024-01-01" /tmp/start
  2. Define the end date: touch --date "2024-02-01" /tmp/end
  3. Now simply craft a find command like this:
find /var/logs/some_dir -type f -newer /tmp/start -not -newer /tmp/end -exec cp "{}" /opt/another/directory \;

NOTE: In the above command, the -exec part of the find uses "{}" as where it puts each filename

@cmbaughman
cmbaughman / win_network_linux.md
Created November 8, 2023 14:17
Notes on Ubuntu as a replacement for Windows AD DC server

Ubuntu as a replacement for Windows Network server

Set up an Ubuntu Server as a standalone Windows network server. In this scenario, we'll assume that you want to replace an existing Windows domain server with the Ubuntu server. Here are the steps:

  1. Install Ubuntu Server:

    • Start by downloading the Ubuntu Server ISO image from the official Ubuntu website.
    • Create a bootable USB drive or mount the ISO on your server.
    • Follow the installation prompts to install Ubuntu Server. During installation, choose the appropriate options for language, keyboard layout, and network configuration.
  2. Configure Network Settings: