Skip to content

Instantly share code, notes, and snippets.

View mcandre's full-sized avatar

Andrew mcandre

  • Milwaukee, WI
View GitHub Profile
@mcandre
mcandre / windows-get-home-directory.md
Created July 1, 2016 22:50
windows get home directory

How to retrieve the current user's home directory from either Command Prompt or PowerShell:

C:\> cmd /c "echo %homedrive%%homepath%"
C:\Users\andrew

PS C:\> cmd /c "echo %homedrive%%homepath%"
C:\Users\andrew
@mcandre
mcandre / windows-which-where.md
Last active July 1, 2016 22:58
Windows equivalent to Unix which

Unix: which <program>

Windows: where.exe <program>

The .exe requirement is due to where being a token of the PowerShell language

@mcandre
mcandre / bootcamp-drivers-win10-hashes.txt
Created June 28, 2016 02:14
Boot Camp drivers for Windows 10
PS C:\Users\andrew\Downloads> .\fciv.exe -both .\BootCamp5.1.5621.zip
//
// File Checksum Integrity Verifier version 2.05.
//
MD5 SHA-1
-------------------------------------------------------------------------
b32fce2718918a7ada6e2153b95c2d1f 72c71be259474836c17ddd400aca2218660b8aac .\bootcamp5.1.5621.zip

The latest BootCamp drivers fail to support Function keys on Apple internal laptop keyboards in Windows 10. To fix this, one can use an older driver.

  1. Download the older BootCamp drivers from https://support.apple.com/kb/DL1720?locale=en_US
  2. Extract the ZIP file contents.
  3. In BootCamp5.1.5621\BootCamp\Drivers\Apple, run AppleKeyboardInstaller64.exe.
@mcandre
mcandre / apple-bluetooth-keyboard-windows-10-bootcamp.md
Created June 14, 2016 18:12
How to fix Apple Bluetooth Wireless Keyboard (Windows 10)

The driver situation with Apple Bluetooth wireless keyboards and Windows 10 is horrible, even with the latest BootCamp drivers. Fortunately, a workaround is available, if you're patient.

Pair keyboard once

  1. Turn on the keyboard.
  2. Press and hold Command + w until the keyboard light begins blinking, indicating the keyboard is ready to pair.
  3. Use Windows Bluetooth settings to pair the keyboard, entering the same code (e.g. 123456 Enter) on both internal and external keyboards.

Pairing the keyboard is very trial and error. 9/10 times, Windows will complain that the keyboard is not available for pairing. Just keep trying.

@mcandre
mcandre / windows-startup.md
Last active June 11, 2016 16:46
How to add arbitrary files to Windows Startup Items
  1. Create a shortcut to the desired file.
  2. Run -> shell:startup
  3. Copy the shortcut to the startup folder.
@htp
htp / curl-websocket.sh
Last active February 8, 2025 05:24
Test a WebSocket using curl.
curl --include \
--no-buffer \
--header "Connection: Upgrade" \
--header "Upgrade: websocket" \
--header "Host: example.com:80" \
--header "Origin: http://example.com:80" \
--header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
--header "Sec-WebSocket-Version: 13" \
http://example.com:80/
@alces
alces / ansible_local_playbooks.md
Last active May 6, 2025 11:00
How to run an Ansible playbook locally
  • using Ansible command line:
ansible-playbook --connection=local 127.0.0.1 playbook.yml
  • using inventory:
127.0.0.1 ansible_connection=local
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active April 25, 2025 15:35
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@drmalex07
drmalex07 / README-oneshot-systemd-service.md
Last active July 7, 2024 19:47
An example with an oneshot service on systemd. #systemd #systemd.service #oneshot

README

Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/setup-foo.sh: