Skip to content

Instantly share code, notes, and snippets.

peaeater / tif2dzi.ps1
Created Jun 22, 2022
DZI Deep Zoom Images from TIFs, requires libvips (
View tif2dzi.ps1
1. Leaf
Given a text file of TIF/TIFF filenames, create DZI (Deep Zoom Image) tiles from TIFs
and create a mirror directory structure for DZI file outputs.
* Handles filenames with entry separators
* Ignores TIF older than its DZI mirror unless -force param is used
* Requires libvips (
.\tif2dzi.ps1 -in c:\dev\abc\extract\extracted\tifs\abc-tifs-1.txt `
View replace-server-in-cbs.ps1
Peter Tyrrell, Andornot
Replaces old sql server name with new in textbase binary *.cbs file.
Note: Uses PowerShell Core syntax. See comments for Windows PowerShell.
Note: Server names of different lengths corrupt the file.
param (
peaeater / force-latest-tls.ps1
Created Dec 1, 2021
Tells .net to use strongest available TLS. Global setting - modifies registry keys.
View force-latest-tls.ps1
Modifies regedit to tell all versions of .NET to use strongest available TLS. Global setting.
Requires admin privileges.
Peter Tyrrell
# check for admin
if (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning ("You do not have admin privileges. Re-run this script as an administrator.")
peaeater / sftp-dir-to-remote.ps1
Created Oct 19, 2020
Powershell using WinSCP to sync directories over SFTP with file mask.
View sftp-dir-to-remote.ps1
Sync a local to remote directory in SFTP mode
[Parameter(Mandatory = $false, Position = 0)]
[string]$logsrc = "",
[Parameter(Mandatory = $true, Position = 1)]
[Parameter(Mandatory = $true, Position = 2)]
peaeater / Global.asax.cs
Created Sep 28, 2020
Force ImageResizer to authorize images larger than thumbnail based on user role in ASP.NET MVC
View Global.asax.cs
protected void Application_Start()
// various setup bits here...
Config.Current.Pipeline.AuthorizeImage +=
delegate (IHttpModule sender, HttpContext context, IUrlAuthorizationEventArgs e)
// only restrict ~/media
if (!e.VirtualPath.StartsWith(VirtualPathUtility.ToAbsolute("~/media")))
peaeater / Global.asax.cs
Created May 8, 2020
Castle Windsor and Web API 2 with ASP.NET MVC
View Global.asax.cs
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using Andi.MVC.Core;
using Andi.MVC.Core.Infrastructure.Globalization;
namespace Andi.MVC.Web
public class MvcApplication : System.Web.HttpApplication
peaeater / MediaApiController.cs
Created May 8, 2020
Web API 2 media controller that handles partial content requests
View MediaApiController.cs
public class MediaApiController : ApiController
public HttpResponseMessage Get(string filepath)
var path = HostingEnvironment.MapPath($"~/media/{filepath}") ?? string.Empty;
var mediaType = MediaTypeHeaderValue.Parse(MimeMapping.GetMimeMapping(filepath));
FileStream stream;
peaeater / helper.logging.ps1
Last active Apr 24, 2020
Log Helper writes to Event Log, console host or file depending on log source.
View helper.logging.ps1
Logging functions.
function logError([string]$logsrc, [string]$msg) {
if ([String]::IsNullOrWhiteSpace($logsrc)) {
write-log -msg $msg -level "ERROR"
elseif (@(".txt", ".log").Contains([System.IO.Path]::GetExtension($logsrc)) -eq $true) {
write-log -msg $msg -level "ERROR" -file $logsrc
peaeater / zipline.ps1
Last active Jun 22, 2020
Zip textbases with System.IO.Compression
View zipline.ps1
Zip up textbase files in preparation for FTP sync to Andornot.
Peter Tyrrell,
-textbases c:\path\to\accessions.tba, c:\path\to\descriptions.tba
-out c:\path\to\destination
param (
[string[]] $textbases,
peaeater / archive-project.ps1
Created Oct 31, 2019
Archive an Andi project
View archive-project.ps1
param (
[Parameter(Mandatory = $true)]
[string]$out = "d:\dev-archive"
$extract_output_dir = "$in\extract\extracted\output\*"
remove-item $extract_output_dir -Recurse
Write-Host "Removed $extract_output_dir"