User Tools

Site Tools


start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
start [2026/03/20 07:21] – [Disk performance tests] abeverleystart [2026/06/03 11:48] (current) abeverley
Line 92: Line 92:
   # Maximum width 400px   # Maximum width 400px
   mogrify -resize '400>' *.png   mogrify -resize '400>' *.png
 +
 +===== Comparing and normalising documents =====
 +
 +Use this to compare PDF and word documents:
 +
 +  * Same the word document as plain text
 +  * Use ''pdftotext'' to convert the PDF to plain text
 +
 +Use this Perl script to normalise each file:
 +
 +  my $str = do { local $/; <STDIN> };
 +  # Strip paragraph numbers
 +  $str =~ s/^[0-9.]+/\n\n/mg;
 +  # Remove wrapped lines that are not paragraph separators
 +  $str =~ s/(?<!\n)\n(?!\n)/ /g;
 +  # Strip space at beginning of lines
 +  $str =~ s/^\h+//mg;
 +  # Normalise paragraph breaks
 +  $str =~ s/\v\v+/\n\n/g;
 +
 +Compare both files using ''git diff --word-diff=color''
  
 ===== Using Overlay (OpenStreetMap) ===== ===== Using Overlay (OpenStreetMap) =====
  
 [[overlay|Using Overlay to extract data from OpenStreetMap]] [[overlay|Using Overlay to extract data from OpenStreetMap]]
 +
 +===== Quick and dirty string dumping in Perl =====
 +
 +From https://blogs.perl.org/users/mauke/2026/04/quick-and-dirty-string-dumping.html
 +
 +A non-obvious feature of sprintf can help here: sprintf('%vd', $string) gives the decimal values of all code points in $string separated by dots. For example:
 +
 +  sprintf('%vd', "abc\n\a") is 97.98.99.10.7
 +  sprintf('%vd', "\xe2\x82\xac") is 226.130.172
 +  sprintf('%vd', "\x{20ac}") is 8364
 +
 +Don't like decimal character codes? Use hex instead:
 +
 +  sprintf('%vx', "abc\n\a") is 61.62.63.a.7
 +  sprintf('%vx', "\xe2\x82\xac") is e2.82.ac
 +  sprintf('%vx', "\x{20ac}") is 20ac
 +
 +Don't like dots? Use whatever separator you want:
 +
 +  sprintf('%*vd', '~', "abc\n\a") is 97~98~99~10~7
  
 ===== Using iptables and PHP to create a captive portal ===== ===== Using iptables and PHP to create a captive portal =====
start.1773991277.txt.gz · Last modified: by abeverley