Skip to content

Instantly share code, notes, and snippets.

@anshumanb
anshumanb / psreadline-disabled-fix.reg
Created July 19, 2022 23:36
Re-enable PSReadLine when PowerShell disables it
Windows Registry Editor Version 5.00
; https://serverfault.com/questions/1014754/cause-of-warning-powershell-detected-that-you-might-be-using-a-screen-reader-an
[HKEY_CURRENT_USER\Control Panel\Accessibility\Blind Access]
"On"="0"
@anshumanb
anshumanb / config.yml
Last active May 25, 2022 12:38
Github CLI settings
# What protocol to use when performing git operations. Supported values: ssh, https
git_protocol: https
# What editor gh should run when creating issues, pull requests, etc. If blank, will refer to environment.
editor: vim
# When to interactively prompt. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled
prompt: enabled
# A pager program to send command output to, e.g. "less". Set the value to "cat" to disable the pager.
pager:
# Aliases allow you to create nicknames for gh commands
aliases:
@anshumanb
anshumanb / keybindings.json
Last active May 25, 2022 00:54
VSCode setup
[
{
"key": "ctrl+shift+i",
"command": "editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
},
{
"key": "shift+alt+f",
"command": "-editor.action.formatDocument",
"when": "editorHasDocumentFormattingProvider && editorTextFocus && !editorReadonly && !inCompositeEditor"
@anshumanb
anshumanb / npm.js
Last active May 25, 2022 00:35
Call NPM from Node
#!/usr/bin/env node
import { spawnSync } from "child_process";
spawnSync("npm", ["--version"], {
encoding: "utf-8",
shell: true,
stdio: [process.stdin, process.stdout, process.stderr],
cwd: process.cwd(),
});
@anshumanb
anshumanb / settings.json
Last active May 20, 2022 11:51
My Windows Terminal config
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions": [
{
"command": {
"action": "quakeMode"
},
"keys": "alt+`"
},
{
@anshumanb
anshumanb / windows-10-focus-follows-mouse.md
Created July 20, 2021 05:54
Set up focus follows mouse on Windows 10
  1. Navigate to Control Panel > Ease of Access > Ease of Access Center > Make the mouse easier to use
  2. Check "Activate a window by hovering over it with the mouse" and hit OK
  3. In the registry editor, navigate to Computer\HKEY_CURRENT_USER\Control Panel\Desktop
  4. Update ActiveWndTrkTimeout to 300
  5. Update UserPreferencesMask by subtracting 40 bits from the first hex value e.g. DF -> 9F
  6. Log out and log back in

Source: https://winaero.com/enable-xmouse-window-tracking-windows-10/

@anshumanb
anshumanb / caps-lock-is-left-ctrl.reg
Last active July 19, 2021 02:54
Remap Windows 10 Ctrl, Win keys
Windows Registry Editor Version 5.00
; https://gist.github.com/joshschmelzle/5e88dabc71014d7427ff01bca3fed33d
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
@anshumanb
anshumanb / commit-to-repo.yml
Created April 18, 2021 06:31
Commit the result of a Github Actions job to its repository
# Adapted from
# https://github.com/actions/checkout/blob/25a956c84d5dd820d28caab9f86b8d183aeeff3d/README.md#push-a-commit-using-the-built-in-token
# https://stackoverflow.com/a/8123841/822292
name: Commit the result of this Github Actions job to this repository
on: push
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Checkout code
@anshumanb
anshumanb / json.js
Last active December 19, 2021 23:27
NodeJS read/write JSON
const fs = require("fs/promises");
const readJson = async (filePath) =>
JSON.parse(await fs.readFile(filePath, "utf-8"));
const writeJson = async (filePath, data) =>
fs.writeFile(filePath, JSON.stringify(data, null, 2).concat("\n"), "utf-8");
@anshumanb
anshumanb / login_win7
Created November 20, 2015 02:02
Auto-login for Windows 7 VirtualBox VM. Uses gnome-keyring to retrieve password.
#!/usr/bin/python2
"""
This code is old. I would probably use secret-tool and
Python's subprocess to extract the password now.
"""
import sys
import time
import gnomekeyring as gk