Skip to content

Instantly share code, notes, and snippets.

@peaeater
peaeater / Default (Windows).sublime-keymap
Last active August 29, 2015 14:03 — forked from LeVM/Default (OSX).sublime-keymap
Insert accented characters in Sublime Text 3
[
{ "keys": ["ctrl+\\","a","`"], "command": "insert", "args": {"characters": "à"} },
{ "keys": ["ctrl+\\","a","^"], "command": "insert", "args": {"characters": "â"} },
{ "keys": ["ctrl+\\","e","'"], "command": "insert", "args": {"characters": "é"} },
{ "keys": ["ctrl+\\","e","`"], "command": "insert", "args": {"characters": "è"} },
{ "keys": ["ctrl+\\","e","^"], "command": "insert", "args": {"characters": "ê"} },
{ "keys": ["ctrl+\\","e",":"], "command": "insert", "args": {"characters": "ë"} },
{ "keys": ["ctrl+\\","i",":"], "command": "insert", "args": {"characters": "ï"} },
{ "keys": ["ctrl+\\","i","^"], "command": "insert", "args": {"characters": "î"} },
{ "keys": ["ctrl+\\","o","^"], "command": "insert", "args": {"characters": "ô"} },
@peaeater
peaeater / alphanumeric-field-type.xml
Last active September 16, 2022 09:21
Alphanumeric field type for Solr which lowercases, removes leading articles, and forces numbers to sort numerically.
<fieldType name="alphaNumericSort" class="solr.TextField" sortMissingLast="false" omitNorms="true">
<analyzer>
<!-- KeywordTokenizer does no actual tokenizing, so the entire
input string is preserved as a single token
-->
<tokenizer class="solr.KeywordTokenizerFactory"/>
<!-- The LowerCase TokenFilter does what you expect, which can be
when you want your sorting to be case insensitive
-->
<filter class="solr.LowerCaseFilterFactory" />
@peaeater
peaeater / pdf2png.ps1
Last active June 7, 2023 18:26
Converts PDF pages to PNGs with imagemagick.
# convert pdf to png
# requires imagemagick w/ ghostscript
param (
[Parameter(Mandatory=$true,ValueFromPipeline=$true,Position=0)]
[ValidateScript({[System.IO.Path]::GetExtension($_) -eq ".pdf"})]
[string]$in,
[string]$magick = "C:\utils\imagemagick\ImageMagick-7.1.1-Q16-HDRI\magick.exe"
)
@peaeater
peaeater / png2jpg.ps1
Created November 10, 2014 23:57
Converts PNGs to JPGS with imagemagick.
# convert pngs to jpgs
# requires imagemagick
Param(
[int]$size = 1000,
[string]$indir = ".",
[string]$outdir = $indir
)
if (!(test-path $outdir)) {
@peaeater
peaeater / ocr.ps1
Last active June 7, 2023 18:16
OCRs image file to plain text with tesseract.
# ocr tif/png to txt
# requires tesseract
Param(
[string]$ext = "tif",
[string]$indir = ".",
[string]$outdir = $indir,
[string]$tesseract = "C:\utils\tesseract\tesseract.exe"
)
@peaeater
peaeater / hocr.ps1
Created November 11, 2014 00:00
OCRs image file to text with coordinate info in hocr format with tesseract.
# ocr tif/png to hocr (html)
# requires tesseract
Param(
[string]$ext = "tif",
[string]$indir = ".",
[string]$outdir = $indir
)
if (!(test-path $outdir)) {
@peaeater
peaeater / raw-ocr.ps1
Created November 11, 2014 00:01
Converts PDFs to JPGs and OCRed text with imagemagick and tesseract.
<#
Processes raw source pdfs, producing per page: 1 txt, 1 hocr, 1 jpg.
Requires imagemagick w/ ghostscript, tesseract.
Subscripts: pdf2png.ps1, ocr.ps1, hocr.ps1, png2jpg.ps1
#>
param(
[string]$indir = ".",
[string]$outbase = $indir
@peaeater
peaeater / solr-dih-transform-order-sample.xml
Created November 12, 2014 19:58
Sample Solr DIH entity demonstrating the order in which transformers act.
<entity
name="sample"
transformer="RegexTransformer,TemplateTransformer">
<field column="test_ignored" template="BLAH" />
<field column="test_ignored" sourceColName="id" regex="(.+)" />
<!--
test_ignored will equal 'BLAH' because TemplateTransformer acts last,
even though it is written first.
@peaeater
peaeater / harvest2qbooks.ps1
Last active August 29, 2015 14:18
Convert Harvest timer CSV export to Quickbooks import format
<#
Peter Tyrrell, 2015
Convert Harvest time report to Quickbooks import format in Windows-1252.
#>
param (
[string]$indir = ".",
[string]$outdir = $indir
)
@peaeater
peaeater / AppPoolResurrector.ps1
Last active July 30, 2018 00:28
Restarts named application pool if stopped, writes restart event to the Windows Application Event Log.
# restarts named app pool if stopped, writes restart event to the Application Event Log
# Peter Tyrrell, May 13 2013
param(
[string[]]$names = (,"ISAPI Webpublisher")
)
# If OS < Server 2008 R2, install Powershell snap-in for IIS and uncomment:
#Add-PSSnapin WebAdministration