Skip to content

Instantly share code, notes, and snippets.

@s-h-a-d-o-w
s-h-a-d-o-w / timecmd.bat
Created October 24, 2024 22:36
Measure execution time for a command, like `time` on Linux.
@echo off
setlocal
for /f "tokens=1-4 delims=:.," %%a in ("%time%") do (
set /a "start=((((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100)"
)
cmd /c %*
for /f "tokens=1-4 delims=:.," %%a in ("%time%") do (
@s-h-a-d-o-w
s-h-a-d-o-w / scrollbar-reset.css
Last active November 4, 2024 12:20
Scrollbar "reset" - get simple, native-style scrollbars everywhere. (Use with the "Stylus" browser extension.)
* {
scrollbar-width: auto !important;
/* Styling color is necessary for all scrollbars
to use the custom styles below on Chrome. */
scrollbar-color: auto !important;
}
*::-webkit-scrollbar {
all: initial !important;
background: #f1f1f1 !important;
@s-h-a-d-o-w
s-h-a-d-o-w / imgburn-window-restore.reg
Created July 24, 2024 21:17
Restores imgburn windows that have disappeared
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\ImgBurn]
"DiscLayoutEditorWindow"=-
"DiscLayoutEditorWindowDiscFilesColumnWidth"=-
"DiscLayoutEditorWindowDiscFilesSortOrder"=-
"DiscLayoutEditorWindowDiscFoldersPercentage"=-
"DiscLayoutEditorWindowExplorerFilesColumnWidth"=-
"DiscLayoutEditorWindowExplorerFilesSortOrder"=-
"DiscLayoutEditorWindowExplorerFoldersPercentage"=-
@s-h-a-d-o-w
s-h-a-d-o-w / pm.bat
Created June 28, 2024 11:09
Batch script - "smart" package manager command for JS projects
@echo off
setlocal
if exist package-lock.json (
set PM=npm
) else if exist yarn.lock (
set PM=yarn
) else if exist pnpm-lock.yaml (
set PM=pnpm
) else if exist bun.lockb (
@s-h-a-d-o-w
s-h-a-d-o-w / git-search.sh
Created May 3, 2024 18:27
Search the git commit history for a string, with optional duration limit
#!/bin/bash
if [ "$#" -lt 1 ]; then
echo "Usage: $0 <search-string> [last X days]"
exit 1
fi
if [ "$#" -eq 1 ]; then
git --no-pager log --grep="$1"
else
@s-h-a-d-o-w
s-h-a-d-o-w / docker.json
Created September 17, 2023 12:34
docker API spec v1.43 converted to OAS3 + regex fix
{
"openapi": "3.0.1",
"info": {
"title": "Docker Engine API",
"description": "The Engine API is an HTTP API served by Docker Engine. It is the API the\nDocker client uses to communicate with the Engine, so everything the Docker\nclient can do can be done with the API.\n\nMost of the client's commands map directly to API endpoints (e.g. `docker ps`\nis `GET /containers/json`). The notable exception is running containers,\nwhich consists of several API calls.\n\n# Errors\n\nThe API uses standard HTTP status codes to indicate the success or failure\nof the API call. The body of the response will be JSON in the following\nformat:\n\n```\n{\n \"message\": \"page not found\"\n}\n```\n\n# Versioning\n\nThe API is usually changed in each release, so API calls are versioned to\nensure that clients don't break. To lock to a specific version of the API,\nyou prefix the URL with its version, for example, call `/v1.30/info` to use\nthe v1.30 version of the `/info` endpoint. If the API version specified in\nth
@s-h-a-d-o-w
s-h-a-d-o-w / dkms-module-signing.md
Created October 3, 2021 10:55
Make DKMS sign kernel modules on installation, with full script support and somewhat distro independent

This gist was originally written by dop3j0e

On systems with UEFI Secure Boot enabled, recent Linux kernels will only load signed modules, so it's about time DKMS grew the capability to sign modules it's building.

These scripts are extended and scriptified variants of https://computerlinguist.org/make-dkms-sign-kernel-modules-for-secure-boot-on-ubuntu-1604.html and https://askubuntu.com/questions/760671/could-not-load-vboxdrv-after-upgrade-to-ubuntu-16-04-and-i-want-to-keep-secur/768310#768310 and add some error checking, a passphrase around your signing key, and support for compressed modules.

dkms-sign-module is a wrapper for the more generic sign-modules which can

@s-h-a-d-o-w
s-h-a-d-o-w / nextjs_type-graphql_apollo-server-express.ts
Created October 14, 2019 16:53
Next.js + type-graphql (via apollo-server-express)
import "reflect-metadata";
import { ApolloServer } from "apollo-server-express";
import compression from "compression";
import express from "express";
import next from "next";
import { buildSchema } from "type-graphql";
import { UserResolver } from "../experiment/resolvers";
@s-h-a-d-o-w
s-h-a-d-o-w / deploy_caprover.sh
Created October 3, 2019 21:16
Deploy CapRover
# This script might be outdated at some point - refer to the links to update it
# https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository
sudo apt-get update
sudo apt-get --yes install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
@s-h-a-d-o-w
s-h-a-d-o-w / process-listers.js
Last active May 11, 2018 16:05
Node.js benchmark code for comparing process listers (example: Spotify.exe)
const Benchmark = require('benchmark');
const WmiClient = require('wmi-client');
const {snapshot} = require("process-list");
const ps = require('ps-node');
const suite = new Benchmark.Suite;
let wmi = new WmiClient();
// Purpose: See which is fastest at retrieving a suitable data set, not necessarily narrowed down to
// the data actually needed yet.