Skip to content

Instantly share code, notes, and snippets.

@kennwhite
kennwhite / touchid_sudo.md
Last active May 15, 2023 16:17
Enable TouchID in terminal for sudo on macOS

sudo vi /etc/pam.d/sudo

Add to the end BEGINNING of the file:

auth sufficient pam_tid.so

@kennwhite
kennwhite / Enable sudo TouchID.md
Last active June 4, 2024 14:45
How to run a macOS app as admin using TouchID/password dialog box.

(This isn't specific to Wireshark)

sudo vi /etc/pam.d/sudo

Add to the end BEGINNING of the file:

auth sufficient pam_tid.so

Test with a trivial sudo command, and you should get a TouchID prompt:

@kennwhite
kennwhite / undork_macos_finder_views.sh
Last active June 16, 2023 21:39
Undork macOS & OSX Finder scattering .DS_Store files everywhere and not being consistent about list views
# Use list view in all Finder windows by default
# Four-letter codes for the other view modes: `icnv`, `clmv`, `glyv`
defaults write com.apple.finder FXPreferredViewStyle -string "Nlsv"
# Remove other views, which Finder remembered because of the .DS_Store files:
find ~ -name ".DS_Store" -delete 2>/dev/null
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
@kennwhite
kennwhite / undork right click touchpad mac os.txt
Last active June 6, 2024 21:36
Enable / turn on right click tap on macOS (Ventura) and undork default
System Settings >
Trackpad >
Tracking speed: slightly slower (optional)
Click: Medium
Force Click and haptic feedback: off
Look up & data detectors: off
Tap to click: off
*THEN*
Secondary click: change "Click or Tap with Two Fingers"
@kennwhite
kennwhite / rust_base64_madness.rs
Last active October 2, 2024 13:44
Rust and base64 encoding decode madness
// YOU HAVE LOTS OF...OPTIONS WITH RUST'S BASE64 ECOSYSTEM. base64::decode() was deprecated Jan 2023
//
// use base64; // let key = base64::decode(base64_key); // <=== classic method, but will throw Deprecation warnings
// use base64::prelude::*; // let key = BASE64_STANDARD.decode(base64_key)?;
// use data_encoding::BASE64; // let key = BASE64.decode( b"SGVsbA...gh=" ) // b prefix is required
// use base64::{Engine as _, alphabet, engine::{self, general_purpose}}; // let key = general_purpose::STANDARD.decode(...);
// use base64::{Engine as _, engine::{general_purpose}}; // let key = general_purpose::STANDARD.decode(...);
// use base64::{Engine as _, engine::general_purpose}; // let key = general_purpose::STANDARD.decode(...);
// use base64::{Engine as _, engine::{general_purpose::STANDARD as base64}}; // let key = base64.decode(...); // DANGER!!
// use base64::{Engine as _, engine::{general_purpose as BASE64}}; // let key = BASE64::STANDARD.decode(...);
@kennwhite
kennwhite / build_mongodb_from_source_centos_9.sh
Created May 1, 2023 13:18
Reproducibly build MongoDB (7.0.0-rc0) from source on CentOS 9 Streams
# Reproducible CentOS 9 Streams install steps for mongod v. 7.0.0
# Cent 8 doesn't support g++-11.3
#
# NOT MEANT AS A TRUE SCRIPT -- SOME INTERACTION IS REQUIRED FROM PROMPTS
#
# THIS IN NO WAY IS OFFICIAL, OR REPRESENTS MongoDB Inc. USE AT YOUR OWN RISK
#
# Get ami # for official CentOS 9 Stream from https://www.centos.org/download/aws-images/
@kennwhite
kennwhite / build_mongodb_from_source_debian_11.sh
Last active February 7, 2024 06:04
Reproducibly build MongoDB (7.0.0-rc0) from source on Debian 11 Bullseye
# Reproducible Debian 11 install steps for mongod v. 7.0.0 (defaults to gcc/g++ v 12, not 11, which requires more steps)
# NOT MEANT AS A TRUE SCRIPT -- SOME INTERACTION IS REQUIRED FROM PROMPTS
# DO NOT DO run apt get autoremove !!!
#
# THIS IN NO WAY IS OFFICIAL, OR REPRESENTS MongoDB Inc. USE AT YOUR OWN RISK
#
# Get ami # for Debian 11 Bullseye, from: https://wiki.debian.org/Cloud/AmazonEC2Image/Bullseye
echo 'deb http://http.us.debian.org/debian/ testing non-free contrib main' | sudo tee -a /etc/apt/sources.list >/dev/null
sudo apt -y update
@kennwhite
kennwhite / MongoDB_bindIp_solution.md
Last active November 6, 2024 19:55
Misconceptions about MongoDB network binding ("net.bindIp")
from __future__ import division
import numpy as np
RADIUS_OF_EARTH_IN_KM = 6371.01
def haversine(lat1, lon1, lat2, lon2):
"""
Utility to calcutlate distance between two pointtodo explain regarding height
coverting from geodisc co-ordinate to cartestian gives errors when distances are further apart
@kennwhite
kennwhite / merkel.json
Created January 16, 2023 18:15
Mock records for testing subdocuments and extended json EJSON-style dates (this is all fake data)
[{
"name": "Angela Merkel",
"dob": {
"$date": {
"$numberLong": "-487900800000"
}
},
"phone": "+49 30 182722720",
"address": {
"street": "Willy-Brandt-Straße 1",