Skip to content

Instantly share code, notes, and snippets.

@kennwhite
kennwhite / reset_osx_attributes.sh
Created September 1, 2013 03:10
Remove all extended attributes recursively on an OSX directory & files and fix "chown: ... Operation not permitted" and "chmod: ... Operation not permitted"
# This is the nuclear option. Use with extreme care
# Works up to and including Mountain Lion (10.8.x)
# Show all extended attributes
ls -lOe ~/dir-to-fix
# Remove no-change attributes
sudo chflags nouchg ~/dir-to-fix
# Recursively clear all entended attributes
@kennwhite
kennwhite / alpine_password.sh
Last active July 12, 2023 15:53
Non-interactive user create & password change for Alpine Linux
#! /usr/bin/env sh
# Create unprivileged Alpine linux user. Run this script as root/sudo
# Don't prompt for password and make group same as username, default path & shell
adduser -D -g appuser appuser
# Set a decent random password (aiming for a 256 bit security level, but better than "monkey")
PW=$(head -c 32 /dev/urandom | base64) && echo -e "$PW\n$PW" | passwd appuser && unset PW
@kennwhite
kennwhite / Install_Alpine_Linux_3.3_on_VirtualBox_OSX.md
Last active June 21, 2023 15:05
Howto: Install Alpine Linux 3.3 on VirtualBox OSX

Howto: Install Alpine Linux 3.3 on VirtualBox OSX

  • Latest Standard ISO version x86_64 is recommended (http://alpinelinux.org/downloads/)
  • Create new VM ("Linux 2.6 / 3.x / 4.x (64-bit)")
  • 1 CPU w/ 512BM RAM and 1 GB default (VDI) disk is more than sufficient
  • Default networking (NAT)
  • Boot and add Alpine ISO as attached virtual install media
  • Default root password is blank (though note - ssh PermitRootLogin defaults to disallow blank passwords and: prohibit-password; switch to yes for Host ssh)
  • Run setup-alpine
  • Defaults are fine, but you do want "sys" disk setup to sda, y to confirm
@kennwhite
kennwhite / Makefile
Created February 15, 2018 06:58 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@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_macos.txt
Last active June 9, 2023 15:15
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: Click or Tap with Two Fingers
@kennwhite
kennwhite / fix_postgres_initdb_error.md
Last active May 18, 2023 12:06
Postgres CentOS and Amazon Linux initdb error: Data directory is not empty! [FAILED]

If completely wiping & reinstalling a Postgres DB, when running initdb like:

service postgresql-9.2 initdb -E 'UTF8' --pgdata="/foo/bar/"

you can encounter this service error:

Data directory is not empty! [FAILED]

To fix it (and this is the nuclear option -- all db data is wiped!)

@kennwhite
kennwhite / Enable sudo TouchID.md
Last active May 16, 2023 11:37
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 / 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 / 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(...);