Inkscape

Inkscape is a free, platform independent tool to work on vector graphics like svgs. Additionally it has got good commandline batch processing facilities which makes it the tool of choice for programmers.

See an example of how to crop or trim many svg files by commandline.

Inkscape to Batch Convert Image Files

Eps to Svg

Inkscape and Eps on Windows

Inkscape on Windows cannot handle eps-files by default. To be able to handle eps-files, it needs Ghoststcript. A fine description of what is to do to install Ghostscript so that Inkscape can handle eps files.

Script

To convert a lot of eps files to svg files at once, you can use tclkitsh and the following script:

set pathToInkscape "C:/Program Files/Inkscape/inkscape.exe"
set epsFiles [glob *.eps]

foreach f $epsFiles {
    set fbasename [file rootname [file tail $f]]
    if ![file exists $fbasename.svg] {
        puts  "$pathToInkscape  $f --export-plain-svg=$fbasename.svg"
        exec  $pathToInkscape $f --export-plain-svg=$fbasename.svg
    }
}

How?

  1. Save the script as EpsToSvg.tcl.
  2. Open the script in an editor and adapt the pathToInkscape. Save.
  3. Open a command shell and cd to the directory where your eps files are located.
  4. Then run tclkitsh EpsToSvg.tcl.

Svg to Pdf

To convert a lot of svg files to pdf files at once, you can use tclkitsh and this script:

This script creates one pdf from every svg in the current directory. 

set pathToInkscape "C:/Program Files/Inkscape/inkscape.exe"
set inputFiles [glob *.svg]

foreach f $inputFiles {
    set fbasename [file rootname [file tail $f]]
    if ![file exists $fbasename.pdf] {
        puts  "$pathToInkscape  $f --export-pdf=$fbasename.pdf"
        exec  $pathToInkscape $f --export-pdf=$fbasename.pdf
    }
}

Inkscape Without Gui

There is the additional commandline parameter -z or --without-gui which prevents that Inkscape opens a window when using with commandline only. Pitily, it seems that most of the --verb commands do not work without gui. It’s been reported as bug in 2011 but not fixed until at least 2017.

Online Regex Tester and Regex Cheat Sheet

A .NET online regex tester: http://regexstorm.net/tester

RexEgg is a site containing black belt stuff concerning regexes and also a regex cheat sheet.

Another site containing fine info about Regexes.

One more, called Regextutorial.

Shorthands for character classes and anchors

Regex What it Matches Inversion
\d [0-9] or with Unicode all digits. Not in AWK. \D
\w [A-Za-z0-9_] or with Unicode all word characters \W
\s [ \t\r\n\f] or all whitespace \S
\b, AWK and Tcl:\y Matches the boundary at the start or end of a word. Is \y in AWK and Tcl as there \b means backspace. \B, Tcl: \Y

Some specialties

All of these specialties do not work in AWK nor in GAWK. They do work in Perl, probably.

Regex Name What it Does
(?:bar) non-capturing Matches bar, but doesn’t capture it.
(?=foo) lookahead Asserts that what immediately follows the current position in the string is foo.
(?<=bar) lookbehind Asserts that what immediately precedes the current position in the string is bar.
(?!baz) negative lookahead Asserts that what immediately follows the current position in the string is not baz.
(?<​!foo) negative lookbehind Asserts that what immediately precedes the current position in the string is not foo.
(?i) case-insensitive Turns on case-insensitive matching. Not in AWK. AWK has no really short way to match case-insensitive. One can use BEGIN{IGNORECASE=1} as starting block or tolower($0)~/abc/ instead of /abc/
(?m) multi-line Turns on multi-line mode. $ and ^ match at any line, not only at begin and start of text. Not in AWK.
(?x) comment Activates comment-mode. Whitespace is ignored and a # in a line starts a comment. Not in AWK.
\b AWK:\y word boundary Matches the boundary at the start or end of a word. \y in AWK as there \b means backspace.
(?<​g>xi) named group Matches xi and gives the capture group the name g. Access to group in code: m.groups["g"]. Only in .NET like this. Some other systems have other possibilities for named groups.

Bash, Awk on Windows: Git-Bash and ConEmu

Every developer who has worked for some time on Linux or another Un*x system will miss the bash, some of the other unix tools like find, cat, grep and awk and a decent console bitterly.

There are several ways how to get some of the unix power back to windows.

  • Cygwin. It is sometimes a bit complicated to install and handle and there are often problems with line endings. I have used this but never was really totally content.
  • MinGW, MSYS and MSYS2. I have never used them and cannot tell much about them.
  • Git-Bash and ConEmu. Lately I have detetcted these tools and it seems they are working quite well. In this post, I’ll go a bit deeper on them. Git-Bash is a version of mingw32, as far as I know.

Git Bash

Git is a well known source control system. And its installation kit for windows contains bash, awk, grep, find and several other unix tools. So even if you don’t want to use git on your windows machine, you can install this package. It is free software.

Installation (with Git 1.9.5 from 2015/03/19) goes like this:

  1. Download the git package for windows.
  2. Run the installer.
    • Install it to tools/Git. Next.
    • Leave away Windows Explorer integration. Do not associate file endings. Next.
    • Do not create a start menu folder. Next.
    • Use Git from Git Bash only. (Other options didn’t work as intended anyway.)
    • Next. Check out Windows-style, commit Unix-style line endings.
    • Next. Wait. Finish.
  3. Create a home directory for your unix tools where you like it. Create an environment variable called HOME pointing to this directory.
  4. Add to your PATH environment variable the directory C:/tools/Git/bin.
  5. Into the directory pointed to by HOME, put a .bashrc with some aliases.
  6. Make sure that your .bashrc contains this line:
    PATH=/bin:$PATH
    This makes sure that the bash tools find and sort are in the PATH before the windows tools with the same names.
  7. Set the Double Commander terminal command to C:/tools/Git/bin/bash.exe.
  8. Done and works. Now you’ve got a usable bash with pipes and filters, awk, find, grep etc available.

ConEmu

ConEmu is a very fine terminal emulator. Download the ConEmu portable package. It’s got dozens of settings and it can be used for any consoles on windows, not only the bash. E.g. it can be used with the ordinary cmd, too.

Here is how to install it:

  1. Download the portable version of ConEmu.
  2. Extract it beneath the Git directory, to C:/tools/ConEmu.
  3. Run ConEmu.exe or ConEmu64.exe, depending on your system. Delete the other one.
  4. Select as settings location C:/tools/ConEmu/ConEmu.xml
  5. As startup task select {Bash::Git bash}.
  6. Done. Now you’ve got a nice looking console window with your git-bash inside. And for the occasional case you still need a cmd console, you can start this also inside ConEmu.
  7. And the best, you have all these things in the console you’ve missed your whole life:
    • You can copy text to the clipboard by just marking it.
    • You can insert text by typing Ctrl-v. Yes, really. No need to Alt-Space-Edit-Paste.
    • You can resize even the width of the window by dragging at the corner. Shocking.
    • ConEmu remembers its position and size and reopens at the previous place
    • There are dozens of other settings and possibilities for configuration with which you can play if you’d like to.
  8. Set the Double Commander terminal command to:
    C:/tools/ConEmu64.exe -here

000005

I’ve got the idea of combining ConEmu with Git on Windows from this post.

Things I like to have in my .bashrc:

PATH=/bin:$PATH

alias cd='pushd'
alias -- -='popd'

alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'

alias ls='ls -ACF'
alias ll='ls -l'

alias no='notepad++'

Zoomit

0516-160353-ZoomitAs a software developer who does UI, you’ll sometimes need to see exactly what is shown on your screen. You need to see pixels. You need to see pixels in large.

Mark Russinovich has built a tool called Zoomit.exe with which you can zoom into the screen fast.

It’s got these additional features:

  • From Vista on, it does even live zoom.
  • You can draw lines, straight lines, rectangles, ellipses.
  • You can write text.
  • The tool has been built as support for presentations, so it’s got a break function.

Though I use it only for zooming, I like it.