{"id":19917126,"url":"https://github.com/katolaz/psrw","last_synced_at":"2026-02-08T08:06:55.052Z","repository":{"id":90385732,"uuid":"125705800","full_name":"KatolaZ/psrw","owner":"KatolaZ","description":"2D radom walk in Postscript","archived":false,"fork":false,"pushed_at":"2018-03-18T13:58:04.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-12T05:40:35.264Z","etag":null,"topics":["postscfipt","random-walk","self-modifying-code"],"latest_commit_sha":null,"homepage":null,"language":"PostScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KatolaZ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-18T08:29:30.000Z","updated_at":"2018-03-18T13:58:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"ed144519-0662-49b9-9616-2ee2f1f2f0e7","html_url":"https://github.com/KatolaZ/psrw","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/KatolaZ/psrw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KatolaZ%2Fpsrw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KatolaZ%2Fpsrw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KatolaZ%2Fpsrw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KatolaZ%2Fpsrw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KatolaZ","download_url":"https://codeload.github.com/KatolaZ/psrw/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KatolaZ%2Fpsrw/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270110199,"owners_count":24529009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postscfipt","random-walk","self-modifying-code"],"created_at":"2024-11-12T21:48:52.010Z","updated_at":"2026-02-08T08:06:50.032Z","avatar_url":"https://github.com/KatolaZ.png","language":"PostScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# psrw\n2D radom walk in Postscript\n\nThis is a simple Postscript hack to visualise a 2D random walk. The\ninteresting part is that you get a different trajectory of the random\nwalk every time you open the file `psrw.ps`.\n\nYou can open the file with `gv`:\n\n```\ngv -nosafer -nosafedir psrw.ps\n```\n\nwhere the extra options are needed to disable some security checks. You\ncan also visualise the document with Ghostscript, if you like:\n\n```\ngs psrw.ps\n```\n\nLiked it? Now close the file and reopen it ;-)\n\n_Hint 1_: If you enable the \"Watch File\" option in `gv`, you will get a\nnice slideshow, for some definition of nice.\n\n_Hint 2_: Running `gv` with `-nosafer -nodirsafe` might be a very bad\nidea.\n\n## WTF?\n\nPostscript is a Turing-complete language. This means that you can\nperform any feasible computation in Postscript. Hence, simulating a\nrandom walk in Postscript is not a big fuss at all, also because the\nstandard Postscript definition already includes a pseudo-random number\ngenerator, so you don't need to implement it yourself. The only problem\nis that the pseudo-random number generator needs to be initialised with\na new seed, otherwise you would always visualise the _same_ trajectory.   \n\nThe simple solution implemented in `psrw.ps` is to store the seed in the\nsame file as a comment, and _update_ it at each run.  In practice,\n`psrw.ps` rewrites a slightly modified copy of itself every time you\n\"view\" it, but a user would hardly notice it :-)\n\n## Why?\n\nWell, you don't need a particular reason to write anything like\n`psrw.ps`. I just tried to do something similar around 2001 or 2002,\nwhen I was using Postscript quite heavily, and at that time I did not\nfind a proper way through.  So the simplicity of the solution\nimplemented in `psrw.ps` scratches a long-standing personal itch, and\ntells a lot about my very poor understanding of Postscript...\n\n## No seriously, WHY?\n\nI just wanted to make a point about (not) trusting documents written in\nformats that you don't understand, or that are not freely accessible or\nare poorly or not documented.  \n\nMany _text_ formats out there are Turing-complete or close-to, and some\nviewers  (e.g., for PDF or OpenXML files) include interpreters for other\nTuring-complete languages (like Javascript or VBScript). This mean that\nthese viewers can do almost anything when you \"_open_\" those \"_text_\"\nfiles. The only chance you have is to understand what is going on behind\nthe scenes, or to trust the company that provided the smart viewer. But\ncan you really trust _them_? \n\nIf it was so easy for a Postscript illiterate like me to craft a\ndocument that modifies itself by changing _something_ that you cannot\neven visualise, what else can be done by \"_text_\" files saved in\nproprietary formats?\n\nWell, at this point you should start thinking that you cannot really\n_trust me_ either, even if I sweared that `psrw.ps` does absolutely\nnothing nasty when you \"open\" it. But how can you be sure I am telling\nthe truth? ;-) \n\n\n## Links\n\n- A brief [summary of Poscript\n  commands](http://www.math.ubc.ca/~cass/courses/ps.html)\n\n- A [game of life](https://www.tjhsst.edu/~edanaher/pslife/) written in\nPoscript\n\n- An interesting \n  [proof](https://nixwindows.wordpress.com/2018/03/13/ed1-is-turing-complete/ \n) showing that [ed, the standard text\n  editor](http://wiki.c2.com/?EdIsTheStandardTextEditor) is indeed\nTuring-complete \n\n## License\n\nThis program is (c) 2018 Vincenzo (KatolaZ) Nicosia. You can use,\nmodify, and redistribute it under the terms of the GNU General Public\nLicense, either Version 3 of the License or, at your option, any later\nversion.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatolaz%2Fpsrw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkatolaz%2Fpsrw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkatolaz%2Fpsrw/lists"}