Skip to content

Instantly share code, notes, and snippets.

@kennwhite
kennwhite / rust_base64_madness.rs
Last active May 10, 2023 19:14
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 / MongoDB_bindIp_solution.md
Last active April 26, 2023 04:14
Misconceptions about MongoDB network binding ("net.bindIp")
@kennwhite
kennwhite / North_Indian_Chicken_Korma.md
Last active April 21, 2023 03:18
Vijaya Selvaraju North Indian Chicken Korma
@kennwhite
kennwhite / ubuntu_20_nvidia_fix.md
Last active April 18, 2023 12:14
Ubuntu 20 Nvidia Zoom Fix

More Nvidia/Ubuntu bleeding edge funness

Problem: Failed to initialize NVML: Driver/library version mismatch

dmesg | grep -i nvrm

NVRM: API mismatch: the client has the version

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 / gce_kms_notes.sh
Last active February 24, 2023 14:52
Using Customer-supplied encryption keys with GCP for new full disk encryption in GCE
# These are my notes, circa Jan 17, 2017 for full volume encryption using customer supplied encryption keys (CSEK)
# Caveat emptor.
# Install Google Cloud Platform (GCP) SDK command line tools
curl -s -L -O -J https://sdk.cloud.google.com/
# (inspect and run it)
# Cloud KMS/keyring not needed for one-off volume encryption with CSEKs
# gcloud beta kms keyrings create KEYRING_NAME --location LOCATION
@kennwhite
kennwhite / 1password_sync.md
Last active February 19, 2023 22:29
Syncing 1Password iOS to 1P Mac app (local vault) | Last Updated Feb 2023

Syncing 1Password v 6.8 7.10 iOS to macOS High Sierra Ventura (v 13) 1Password Mac app v 7.9.6 (local vault)

  • Turn off the firewall for OSX (temporarily -- make sure to reenable)
  • Ensure Mac and iOS are on same wifi network (you don't need Bluetooth)
  • 1Password Mac: Preferences / WLAN Server / Check Run a WLAN Server
  • 1Password iOS: WLAN on main screen or Settings/ Sync / Choose WLAN / Enter code from OSX

After Successful Sync (should take < 5 seconds) DON'T FORGET TO DO THIS:

@kennwhite
kennwhite / GeForce_RTX_2070_hashcat.txt
Created February 2, 2020 04:10
GeForce RTX 2070 hashcat
hashcat (v5.0.0) starting in benchmark mode...
* Device #1: WARNING! Kernel exec timeout is not disabled.
This may cause "CL_OUT_OF_RESOURCES" or related errors.
To disable the timeout, see: https://hashcat.net/q/timeoutpatch
OpenCL Platform #1: NVIDIA Corporation
======================================
* Device #1: GeForce RTX 2070, 2048/8192 MB allocatable, 36MCU
OpenCL Platform #2: Intel(R) Corporation
@kennwhite
kennwhite / encrypt_file.go
Last active January 20, 2023 18:22
Simple file encryption with Go using pgp (AES128 + SHA256)
package main
import (
"golang.org/x/crypto/openpgp"
"io/ioutil"
"os"
)
func main() {