Skip to content

Instantly share code, notes, and snippets.

View metadaddy's full-sized avatar

Pat Patterson metadaddy

View GitHub Profile
@metadaddy
metadaddy / b2_multipart.php
Last active April 27, 2024 13:35
PHP sample code for a multipart file upload to Backblaze B2. Usage: php php_multipart.php [-v] <bucket_name> <local_file>
<?php
// PHP sample code to show multipart file upload using the B2 Native API
// User supplies optional -v for verbose output from curl, then bucket name
// and path to local file
$rest_index = null;
$opts = getopt("v::", [], $rest_index);
$args = array_slice($argv, $rest_index);
@metadaddy
metadaddy / put_object_benchmark.py
Created October 14, 2023 00:25
Simple Python app to benchmark file uploads using the S3 PutObject API
# MIT License
#
# Copyright (c) 2023 Backblaze, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
@metadaddy
metadaddy / drivestats2parquet.py
Last active September 9, 2023 03:41
Python code for loading Drive Stats data into Backblaze B2 Cloud Storage
import copy
import os
import re
from datetime import date
from io import BytesIO
from zipfile import ZipFile
import pyarrow as pa
import pyarrow.csv as csv
@metadaddy
metadaddy / makepdfs.py
Created September 1, 2023 17:23
This script uses the PDF file at https://github.com/Snowflake-Labs/snowpark-python-demos/blob/main/pdf-analysis/prod_review10.pdf as a template for creating more PDFs with random names, dates, product selections and recommendations. This PDF file is used in the Snowflake demo "How To Analyze PDF Docs Using Snowpark" at https://www.youtube.com/wa…
# Backblaze wants developers and organization to copy and re-use our
# code examples, so we make the samples available by several different
# licenses. One option is the MIT license (below). Other options are
# available here:
#
# https://www.backblaze.com/using_b2_code.html
#
#
# The MIT License (MIT)
#
This file has been truncated, but you can view the full file.
2023-06-07 12:42:03,490 [main] DEBUG ch.cyberduck.binding.application.NSApplication - NSConcreteNotification 0x60000390e320 {name = NSApplicationWillBecomeActiveNotification; object = <NSApplication: 0x137e3cff0>}
2023-06-07 12:42:03,491 [main] DEBUG ch.cyberduck.binding.WindowController - Become main for window <NSWindow: 0x147e72c50>
2023-06-07 12:42:03,491 [main] DEBUG ch.cyberduck.binding.WindowController - Become key for window <NSWindow: 0x147e72c50>
2023-06-07 12:42:03,493 [main] DEBUG ch.cyberduck.binding.application.NSApplication - NSConcreteNotification 0x60000394d8e0 {name = NSApplicationDidBecomeActiveNotification; object = <NSApplication: 0x137e3cff0>}
2023-06-07 12:42:03,504 [main] DEBUG ch.cyberduck.core.resources.NSImageIconCache - No cached image for eject.pdf
2023-06-07 12:42:03,504 [main] DEBUG ch.cyberduck.core.resources.NSImageIconCache - Return default size for eject.pdf
2023-06-07 12:42:03,656 [main] DEBUG ch.cyberduck.core.resources.NSImageIconCache - No cached image for eject.pdf
@metadaddy
metadaddy / setup.sh
Last active February 14, 2023 08:06
Setup a SalesforceDX scratch org, open an IP range, check we can log in
#! /bin/bash
#
# Requires jq - see https://stedolan.github.io/jq/
#
# Assumes that the following env vars are set:
#
# CLIENT_ID - the client ID for your OAuth 2 app
# JWT_KEY_FILE - path to the private key for creating a JWT
# HUB_USERNAME - authentication username
<# .SYNOPSIS
Create a marker file in each empty directory under a given root directory
.DESCRIPTION
This script recursively finds empty directories under the given root
directory and creates a marker file with the given filename in each one.
.NOTES
Author : Pat Patterson
#>
param (
@metadaddy
metadaddy / Create-MarkerFiles.ps1
Last active December 5, 2022 01:05
PowerShell script to create a marker file in each empty directory under a given root directory
<# .SYNOPSIS
Create a marker file in each empty directory under a given root directory
.DESCRIPTION
This script recursively finds empty directories under the given root
directory and creates a marker file with the given filename in each one.
.NOTES
Author : Pat Patterson
#>
[CmdletBinding(SupportsShouldProcess)]
@metadaddy
metadaddy / sync-deletes.py
Created July 19, 2022 00:54
Delete all files in a destination bucket that do not exist in a source bucket
import os
import sys
import boto3
from botocore.config import Config
from dotenv import load_dotenv
# Use -d command line option for a dry run - i.e. don't actually delete files
dry_run = len(sys.argv) == 2 and sys.argv[1] == '-d'
@metadaddy
metadaddy / Purge All Deleted Objects.js
Last active February 25, 2022 17:40
UserScript to erase all the deleted custom objects from a Salesforce org with one click. In Classic UI, go to Setup | Create | Objects | Deleted Objects and the script should be available.
// ==UserScript==
// @name Purge All Deleted Objects
// @description Erase all deleted custom objects from the Salesforce org
// @include https://*.salesforce.com/p/setup/custent/DeletedEntitiesList?*
// ==/UserScript==
// UserScripts: https://github.com/quoid/userscripts
// Sometimes, when you're testing Salesforce metadata operations, you end up with a
// lot of deleted custom objects in your org. There's no API to erase a deleted object,