Skip to content

Instantly share code, notes, and snippets.

@peaeater
peaeater / zipline.ps1
Last active June 22, 2020 19:55
Zip textbases with System.IO.Compression
<#
Zip up textbase files in preparation for FTP sync to Andornot.
Peter Tyrrell, ptyrrell@andornot.com
-textbases c:\path\to\accessions.tba, c:\path\to\descriptions.tba
-out c:\path\to\destination
#>
param (
[string[]] $textbases,
@peaeater
peaeater / archive-project.ps1
Created October 31, 2019 15:22
Archive an Andi project
param (
[Parameter(Mandatory = $true)]
[string]$in,
[string]$out = "d:\dev-archive"
)
$extract_output_dir = "$in\extract\extracted\output\*"
remove-item $extract_output_dir -Recurse
Write-Host "Removed $extract_output_dir"
@peaeater
peaeater / sitemap.ps1
Created May 30, 2018 16:23
Creates sitemap index with attendant sitemaps from a Solr query.
<#
Create sitemap index with attendant sitemaps from a Solr query.
A new sitemap is created every 50,000 rows.
#>
param (
[string]$ChangeFrequency = "weekly",
[string]$IndexBaseUrl = "http://andi.andornot.com/",
[string]$Logsrc = "Andi Solr Update",
[string]$OutDir = ".\",
@peaeater
peaeater / optimize-pdf.ps1
Created May 25, 2018 17:47
Downsamples PDFs with ghostscript.
<#
Downsample PDF and convert to gray if necessary.
Requires Ghostscript (gswin64c).
#>
param (
[string]$indir,
[string]$outdir = $indir,
[string]$gs = "gswin64c",
[string]$dpi = "150"
@peaeater
peaeater / logger.ps1
Created March 26, 2018 20:41 — forked from barsv/logger.ps1
Logging in powershell with log rotation
# all logging settins are here on top
$logFile = "log-$(gc env:computername).log"
$logLevel = "DEBUG" # ("DEBUG","INFO","WARN","ERROR","FATAL")
$logSize = 1mb # 30kb
$logCount = 10
# end of settings
function Write-Log-Line ($line) {
Add-Content $logFile -Value $Line
Write-Host $Line
@peaeater
peaeater / cd2mp3.ps1
Last active May 4, 2022 17:34
Powershell script that uses VLC to rip a CD audio track.
<#
Rip Audio CD to mp3 files with VLC.
#>
param (
[string]$vlc = "c:\program files\videolan\vlc\vlc.exe",
[string]$cddrive = "E:",
[int]$track = 0
)
@peaeater
peaeater / rip-cd.bat
Created March 7, 2018 15:51
Windows batch file that uses VLC to rip an audio CD
@ECHO OFF
setlocal ENABLEDELAYEDEXPANSION
SET /a x=0
FOR /R E:\ %%G IN (*.cda) DO (CALL :SUB_VLC "%%G")
GOTO :eof
:SUB_VLC
@peaeater
peaeater / prune_elmah.ps1
Created October 31, 2017 15:51
Delete ELMAH_Error table rows from Andi db earlier than today - x days.
param (
[string]$server,
[string]$dbname,
[int]$daysToKeep,
[Parameter(Mandatory=$false)]
[string]$logsrc = "Andi Solr Update"
)
function logError([string]$logsrc, [string]$msg) {
# write error msg to Application EventLog
@peaeater
peaeater / prune_cart.ps1
Created October 31, 2017 15:47
Delete empty CartInstance table rows from Andi db earlier than today - x days.
param (
[Parameter(Mandatory=$true)]
[string]$server,
[Parameter(Mandatory=$true)]
[string]$dbname,
[Parameter(Mandatory=$true)]
[int]$daysToKeep,
[Parameter(Mandatory=$false)]
[string]$logsrc = "Andi Solr Update"
)
@peaeater
peaeater / text-mirror.ps1
Last active June 22, 2022 18:45
Create a text file mirror from PDFs, requires poppler
<#
1. Leaf
Given a text file of PDF filenames, extract content from PDFs recursively
and create mirror directory structure for text file outputs.
* Handles filenames with entry separators.
* Ignores PDF older than its text file mirror unless -force param is used.
* Requires poppler pdftotext.exe
.\text-mirror.ps1 -in C:\dev\abc\extract\extracted\pdfs\abc-pdfs-1.txt `