|
|
@ -20,43 +20,60 @@ gs psrw.ps |
|
|
|
|
|
|
|
|
|
|
|
Liked it? Now close the file and reopen it ;-) |
|
|
|
Liked it? Now close the file and reopen it ;-) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_Hint 1_: If you enable the "Watch File" option in `gv`, you will get a |
|
|
|
|
|
|
|
nice slideshow, for some definition of nice. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_Hint 2_: Running `gv` with `-nosafer -nodirsafe` might be a very bad |
|
|
|
|
|
|
|
idea. |
|
|
|
|
|
|
|
|
|
|
|
## WTF? |
|
|
|
## WTF? |
|
|
|
|
|
|
|
|
|
|
|
Postscript is a Turing-complete language. This means that you can do any |
|
|
|
Postscript is a Turing-complete language. This means that you can |
|
|
|
feasible computation in Postscript. Hence, simulating a random walk in |
|
|
|
perform any feasible computation in Postscript. Hence, simulating a |
|
|
|
Postscript is not a big fuss at all, also because the standard |
|
|
|
random walk in Postscript is not a big fuss at all, also because the |
|
|
|
Postscript definition already includes a pseudo-random number generator, |
|
|
|
standard Postscript definition already includes a pseudo-random number |
|
|
|
so you don't need to implement it yourself. The only problem is that the |
|
|
|
generator, so you don't need to implement it yourself. The only problem |
|
|
|
pseudo-random number generator needs to be initialised with a new seed, |
|
|
|
is that the pseudo-random number generator needs to be initialised with |
|
|
|
otherwise you would always visualise the _same_ trajectory. |
|
|
|
a new seed, otherwise you would always visualise the _same_ trajectory. |
|
|
|
|
|
|
|
|
|
|
|
The simple solution implemented in `psrw.ps` is to store the seed in the |
|
|
|
The simple solution implemented in `psrw.ps` is to store the seed in the |
|
|
|
same file as a comment, and _update_ it after every run. In a word, |
|
|
|
same file as a comment, and _update_ it at each run. In practice, |
|
|
|
`psrw.ps` rewrites itself at each run, changing the seed and allowing to |
|
|
|
`psrw.ps` rewrites a slightly modified copy of itself every time you |
|
|
|
generate a _new_ random walk trajectory every time you open the file. |
|
|
|
"view" it, but a user would hardly notice it :-) |
|
|
|
|
|
|
|
|
|
|
|
## Why? |
|
|
|
## Why? |
|
|
|
|
|
|
|
|
|
|
|
Well, there is no particular reason to write anything like `psrw.ps`. I |
|
|
|
Well, you don't need a particular reason to write anything like |
|
|
|
just tried to do something similar around 2001 or 2002, when I was using |
|
|
|
`psrw.ps`. I just tried to do something similar around 2001 or 2002, |
|
|
|
Postscript quite heavily, and at that time I did not find a proper way |
|
|
|
when I was using Postscript quite heavily, and at that time I did not |
|
|
|
through. The simplicity of the solution implemented in `psrw.ps` |
|
|
|
find a proper way through. So the simplicity of the solution |
|
|
|
scratches a long-standing personal itch, and tells a lot about my poor |
|
|
|
implemented in `psrw.ps` scratches a long-standing personal itch, and |
|
|
|
knowledge of Postscript... |
|
|
|
tells a lot about my very poor understanding of Postscript... |
|
|
|
|
|
|
|
|
|
|
|
## No really, WHY? |
|
|
|
## No seriously, WHY? |
|
|
|
|
|
|
|
|
|
|
|
I just wanted to make a point about (not) trusting documents written in |
|
|
|
I just wanted to make a point about (not) trusting documents written in |
|
|
|
formats that you don't understand, or that are not freely accessible or |
|
|
|
formats that you don't understand, or that are not freely accessible or |
|
|
|
not documented. Many _text_ formats out there are Turing-complete or |
|
|
|
are poorly or not documented. |
|
|
|
close-to, and some visualiser (e.g., for PDF or OpenXML) include |
|
|
|
|
|
|
|
interpreters for other Turing-complete languages (like Javascript or |
|
|
|
Many _text_ formats out there are Turing-complete or close-to, and some |
|
|
|
VBScript). This mean that they can do almost anything when you "_open_" |
|
|
|
viewers (e.g., for PDF or OpenXML files) include interpreters for other |
|
|
|
those "_text_" files. |
|
|
|
Turing-complete languages (like Javascript or VBScript). This mean that |
|
|
|
|
|
|
|
these viewers can do almost anything when you "_open_" those "_text_" |
|
|
|
If it's so easy to craft a document that modifies itself to change a |
|
|
|
files. The only chance you have is to understand what is going on behind |
|
|
|
comment that you can't visualise, what else can be done by "_text_" |
|
|
|
the scenes, or to trust the company that provided the smart viewer. But |
|
|
|
files saved in proprietary formats? |
|
|
|
can you really trust _them_? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If it was so easy for a Postscript illiterate like me to craft a |
|
|
|
|
|
|
|
document that modifies itself by changing _something_ that you cannot |
|
|
|
|
|
|
|
even visualise, what else can be done by "_text_" files saved in |
|
|
|
|
|
|
|
proprietary formats? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Well, at this point you should start thinking that you cannot really |
|
|
|
|
|
|
|
_trust me_ either, even if I sweared that `psrw.ps` does absolutely |
|
|
|
|
|
|
|
nothing nasty when you "open" it. But how can you be sure I am telling |
|
|
|
|
|
|
|
the truth? ;-) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## Links |
|
|
|
## Links |
|
|
|
|
|
|
|
|
|
|
|