tags | created | modified | ||||
---|---|---|---|---|---|---|
|
2024-04-04 01:42:00 -0700 |
2024-04-04 01:42:00 -0700 |
// ---------- | |
// 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! |
/** | |
* 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} |
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 |
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
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' \)
If your Mac reboots, and you want to be notified that it has rebooted.
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.
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
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
- 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
## One liner to remove Duplicates from an array and keep order. | |
old = ['a', 'b', 'a', 'c', 'b', 'a'] | |
new = list(dict.fromkeys(old).keys()) |