Archive for the ‘Scripting’ Category

Simple bash script for showing Farming Simulator mods

Thursday, June 29th, 2017

Throwing this on here for my reference. Given a Farming Simulator 17 save game location it will print out a nice list of the mods in use.


#!/bin/bash

if [ -z "$1" ]; then
    echo "Usage: $(basename $0) "
    exit 1
fi

DIR="$1"

cat "${DIR}/careerSavegame.xml" | \
grep -oP '(?< =modName=").+(?=" version)' | \
sed 's/" title="/ | /' | sort

timestamp in windows

Thursday, October 11th, 2012

http://www.jasonprahl.com/?p=1631

wide wide world of characters

Tuesday, September 11th, 2007

I was getting a lot of “Wide character in print” errors from a perl script. A little googling led me to this page and the solution. In short, I was printing unicode characters to an I/O layer that did not support unicode, hence the error. Adding a call to binmode solved this.

example:

open(FILEHANDLE, “>$filename”);
binmode(FILEHANDLE, “:utf8”);
printf(FILEHANDLE, “Hello World!n”);

Postscript for Encoder Wheels

Thursday, May 17th, 2007

From ranchbots

%! Postscript utility for printing an encoder wheel
%
/inch {72 mul} def % #points/inch (don't change me)
/size 0.5 inch def % radius of encoder wheel
/segments 16 def % number of segments (black and white)
/angle 360 segments div def
/wedge
{ /radius exch def
/angle_s exch def
/angle_e exch def
newpath 0 0 moveto
0 0 radius angle_s angle_e arc
closepath
} def

gsave
1.0 inch 1.0 inch translate
0 1 segments {
360 segments div rotate
angle 0 size wedge
2 mod 0 eq {1} {0} ifelse
setgray fill
} for
grestore

showpage