Skip to content

Instantly share code, notes, and snippets.

View psenger's full-sized avatar
:octocat:
Makin Bacon

Philip A Senger psenger

:octocat:
Makin Bacon
View GitHub Profile
@psenger
psenger / README.md
Created April 10, 2024 23:04
[Definition of Done - DOD] #agile #dod #docs
tags created modified
dod
code-standards
definition
definition-of-done
2024-04-04 01:42:00 -0700
2024-04-04 01:42:00 -0700

Definition of Done ( DOD )

@psenger
psenger / with-cancel.js
Last active April 12, 2024 05:10
[Promise Design Patterns Timeout on Asynchronous Operations] #JavaScript #Promise
// ----------
// Cancel function!
// ----------
// NOTE:
// This allows us to externalize the cancel function..
// kind of like a inversion of control
let expensiveApplication = delayMs => new Promise(resolve => setTimeout(resolve, delayMs))
// Long Running Process - LRP with cancel function!
@psenger
psenger / index.js
Last active March 26, 2024 02:11
[How to programmatically get data in JavaScript directly into your buffer] #MacOS #JavaScript #Node
/**
* Sends a String of data to the Mac OSX Buffer, this is very helpful if
* you are doing something in scratch pad and want to copy it somewhere.
*
* this beats Pipe-ing the output to pbcopy directly.
*
* @param {string} data - Required UTF-8 String to be copied to the buffer.
*
* @return {void}
@psenger
psenger / common-utils.js
Created March 21, 2024 21:45
Compare Travel Insurance
const https = require('https')
const http = require('http')
const readline = require('readline')
const url = require('url')
function httpRequest(options, data) {
return new Promise((resolve, reject) => {
const parsedUrl = url.parse(options.hostname)
const protocol = parsedUrl.protocol
const request = (protocol && protocol.startsWith('https')) ? https.request : http.request
@psenger
psenger / README.md
Created February 15, 2024 23:59
[Exact Copy] #MacOS #Unix

Exact Copy

Copy everything from one directory to another directory on a different volume in Unix, while retaining permissions, ownership, structure, as well as all creation and modification dates (timestamps)

When Destination is Fresh

rsync -avHAX --numeric-ids /source/directory/ /destination/directory/

Caution - removes destination files

@psenger
psenger / README.md
Last active February 11, 2024 22:41
[Find files based on file extensions recursively] #macOS #UNIX #find

To find all files with the extensions .yaml or .yml recursively in Unix / Mac OSX, you can use the find command with this pattern:

find . \( -name '*.yaml' -o -name '*.yml' \)
@psenger
psenger / README.md
Last active January 18, 2024 21:49
[How to "Action" when a Mac Reboot] #MacOS

How to "Action" when a Mac Reboots

If your Mac reboots, and you want to be notified that it has rebooted.

How to launch a Script when your mac reboots

Create a .plist file at /Library/LaunchDaemons/com.YOUR_COMPANY.rebootnotification.plist. Change YOUR_COMPANY to your domain name in the .plist file. The contents will look like the following, change /path/to/your/script.sh to your script. This .plist file and the /path/to/your/script.sh should be owned by root:wheel my advise is to make it only executable by root. I take no responsiblities for any Security issues.

@psenger
psenger / README.md
Last active December 26, 2023 21:32
[Network Quality] #MacOS

Network Quality

networkQuality tests the upload/download capacity and upload/download responsiveness in parallel by default

% networkquality -v
Downlink: capacity 0.000 Mbps, responsiveness 0 RPM (828.687 KB, 1 flows) - Uplink: capacity 5.295 Mbps, responsiveness 0 RPM (191.997 KB, 1 flows
Downlink: capacity 80.816 Mbps, responsiveness 960 RPM (13.951 MB, 2 flows) - Uplink: capacity 6.876 Mbps, responsiveness 960 RPM (1.187 MB, 2 flo
Downlink: capacity 83.615 Mbps, responsiveness 989 RPM (16.483 MB, 2 flows) - Uplink: capacity 7.778 Mbps, responsiveness 989 RPM (1.687 MB, 2 flo
@psenger
psenger / README.md
Last active December 26, 2023 21:36
[SIPS - scriptable image processing system] #MacOS #sips #Image

SIPS (Scriptable Image Processing System)

SIPS (Scriptable Image Processing System) is a command-line utility available on macOS that enables users to perform various image manipulation tasks directly from the command line. It supports a wide range of image file formats, including JPEG, PNG, TIFF, GIF, and more

Example usage:

  • Scale an image (without aspect ratio): sips -z width height input_image --out output_image
  • Scale an image (maintain aspect ratio): sips -z 800 0 original.jpg --out scaled.jpg
  • Query image properties: sips -g dpiHeight -g dpiWidth image.jpg
@psenger
psenger / example.py
Created December 26, 2023 21:14
[Remove Duplicates from an Array and keep order] #Array #Python
## One liner to remove Duplicates from an array and keep order.
old = ['a', 'b', 'a', 'c', 'b', 'a']
new = list(dict.fromkeys(old).keys())