This is especially useful during application startup, giving you time to attach a debugger.
// NB: This assumes a Serilog.ILogger is in scopeif System.Environment.GetEnvironmentVariable "AWAIT_DEBUGGER" = "true" thenlogger.Warning "Waiting for debugger to be attached"while not System.Diagnostics.Debugger.IsAttached do System.Threading.Thread.Sleep 100System.Diagnostics.Debugger.Break ()
#r "nuget: Google.Cloud.Storage.V1"fsi.ShowIEnumerable <- falsefsi.ShowProperties <- falseopen Systemopen Google.Apis.Auth.OAuth2open Google.Cloud.Storage.V1open System.Text.RegularExpressionslet bucket = "bucket-name"// gcloud auth application-default loginlet creds =Environment.SpecialFolder.UserProfile|> Environment.GetFolderPath|> fun home -> GoogleCredential.FromFile $"{home}/.config/gcloud/application_default_credentials.json"let client = StorageClient.Create credslet objects = client.ListObjects bucketlet extensionMatch input = Regex.IsMatch (input, ".jpg|.jpeg|.png|.avif", RegexOptions.Compiled)let images =objects|> Seq.filter (fun obj -> extensionMatch obj.Name)|> Array.ofSeqlet (|DateAfterOrOn|_|) compare dateTime =let cutoff = DateTime.ParseExact (compare, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture)if dateTime >= cutoff then Some () else Noneimages|> Array.groupBy (fun obj ->match obj.TimeCreated |> Option.ofNullable with| Some (DateAfterOrOn "2022-01-01") -> "2022"| Some (DateAfterOrOn "2021-01-01") -> "2021"| Some (DateAfterOrOn "2020-01-01") -> "2020"| Some (DateAfterOrOn "2019-01-01") -> "2019"| Some (DateAfterOrOn "2018-01-01") -> "2018"| Some (DateAfterOrOn "2017-01-01") -> "2017"| Some _ -> "Pre-2018"| None -> "NoDate")|> Array.iter (fun (group, objects) ->printfn "%s: %s" group (String.Format("{0:n}", objects.Length)))