Skip to content

Instantly share code, notes, and snippets.

@paulgalow
paulgalow / synology-cloud-sync-s3-iam-policy.json
Last active August 5, 2022 15:56
Least privilege IAM policy for Synology Cloud Sync with Amazon S3 in bi-directional syncing mode. Tested on DSM 6.2.4.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::*"
@paulgalow
paulgalow / processManifest.js
Last active January 16, 2022 17:28
Post-processing script for 'serverless-manifest-plugin'. Parses manifest output and populates .env file with deployed AWS resource values. Based on: https://github.com/theburningmonk/appsyncmasterclass-backend/blob/873a6bf144e44725c389b198abec5245559fe9bf/processManifest.js
const dotenv = require("dotenv");
const fs = require("fs").promises;
const path = require("path");
module.exports = async function processManifest(manifestData) {
const stageName = Object.keys(manifestData)[0];
const { outputs } = manifestData[stageName];
const envArray = outputs
.map((obj) => Object.values(obj))
.map((arr) => [camelToUpperSnakeCase(arr[0]), arr[1]]);
🔔 UPDATE
GFI has released an official statement

Log4j hotfix against Log4Shell (CVE-2021-44228) for Kerio Connect server instances running on Ubuntu 20.04. Please note that at this point it is unclear to me if Kerio Connect is vulnerable. This is meant as a precaution.

⚠️ This will remove the vulnerable JndiLookup class from log4j-core-2.5.jar. I haven't run into any side effects, but be advised this might cause unintended side effects.

cd /opt/kerio/mailserver/javaservices/im/lib
@paulgalow
paulgalow / get-macos-build.sh
Last active April 18, 2022 00:38
Extract macOS release and build versions from a macOS Big Sur installer. Pass it a path to an InstallAssistant app, like so: ./get-macos-build.sh "/Applications/Install macOS Big Sur.app/"
#!/bin/sh
readonly installAssistant="$1"
# Display error messages and exit script
error() {
echo "[ERROR] $*"
exit 1
}
@paulgalow
paulgalow / checkTCP.js
Last active December 31, 2019 08:17
Check for internet connectivity using TCP
const { createConnection } = require("net");
function checkTCP(host = "1.1.1.1", port = 53) {
return new Promise((resolve, reject) => {
const client = createConnection({ host, port }, () => {
console.log(`TCP connection established on port ${port}`);
client.end();
resolve();
});
@paulgalow
paulgalow / checkHTTP.js
Last active December 31, 2019 07:24
Check for internet connectivity using HTTP
const { parse } = require("url");
function checkHTTP(url) {
return new Promise((resolve, reject) => {
const { protocol } = parse(url);
const lib = protocol === "https:" ? require("https") : require("http");
const request = lib.get(url, response => {
console.log(`HTTP Status Code:`, response.statusCode);
resolve(response);
@paulgalow
paulgalow / rename-photos-videos-timestamp.sh
Last active January 6, 2024 12:52
macOS Automator script to rename photos/videos based on creation date. Blog post: https://paulgalow.com/macos-quick-action-rename-photos-videos-timestamp
#!/bin/bash
# macOS Automator script to rename photos/videos based on creation date
# Blog post: https://paulgalow.com/macos-quick-action-rename-photos-videos-timestamp
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
# Create subfolder to store renamed files
createDestination() {
readonly destination="$(dirname "$file")/sorted"
@paulgalow
paulgalow / FirefoxExtensions.mobileconfig
Last active December 29, 2018 12:29
Example configuration profile to install the uBlock Origin Firefox extension and set domains that can install extensions
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
<key>EnterprisePoliciesEnabled</key>
<true/>
<key>Extensions</key>
@paulgalow
paulgalow / awscreds-lpass.sh
Last active August 17, 2020 19:02
Get AWS CLI IAM credentials from LastPass CLI. Blog post: https://paulgalow.com/securing-aws-credentials-macos-lastpass
#!/bin/bash
# Get AWS CLI IAM credentials from LastPass CLI
# Blog post: https://paulgalow.com/securing-aws-credentials-macos-lastpass
# ##############################################################################
# Please adjust those properties
readonly lastPassEntry="REPLACE-ME" # Name of LastPass entry that stores your IAM credentials
readonly lpass="/usr/local/bin/lpass" # Path to LastPass CLI
# ##############################################################################
#!/usr/bin/swift
import AppKit
func generateMacIcon(dimension: CGFloat, name iconName: String) {
// Make sure our maximum rendering size does not exceed 512 px
guard dimension <= 512 else {
print("Error: Maximum dimension allowed is 512")
return