Spenser Truex

Newport
posted on 2019-4-28

Revive the portable OS interface library portions of CLOCC's PORT, with modern implementations and ASDF.

Code is on github!

Portable shell and system access. Revive the portable OS interface library portions of CLOCC's PORT, with modern implementations and ASDF. Provide better documentation than was ever offered at the now bit rotten site. Licensed with LGPL (through mandate, since the original was).

Shell, Pipes, System functions

CURRENT-TIME

Print the current time to the stream (defaults to t).

STRING->TZ

Find the OBJ (symbol or string) in +TIME-ZONES+.

TZ->STRING

Convert the CL timezone (rational [-24;24], multiple of 3600) to a string.

+TIME-ZONES+

*The string representations of the time zones.

+WEEK-DAYS+

*The names of the days of the week.

+MONTH-NAMES+

*The names of the months.

SYSINFO

Print the current environment to a stream.

STRUCTURE-PREDICATE

Return the structure predicate name.

STRUCTURE-COPIER

Return the structure copier name.

STRUCTURE-BOA-CONSTRUCTORS

Return the list of structure BOA constructor names.

STRUCTURE-KEYWORD-CONSTRUCTOR

Return the structure keyword constructor name.

STRUCTURE-SLOTS

Return the list of structure slot names.

CLASS-SLOT-INITARGS

Return the list of initargs of a CLASS. CLASS can be a symbol, a class object (as returned by `class-of') or an instance of a class. If the second optional argument ALL is non-NIL (default), initargs for all slots are returned, otherwise only the slots with :allocation type :instance are returned.

CLASS-SLOT-LIST

Return the list of slots of a CLASS. CLASS can be a symbol, a class object (as returned by `class-of') or an instance of a class. If the second optional argument ALL is non-NIL (default), all slots are returned, otherwise only the slots with :allocation type :instance are returned.

ARGLIST

Return the signature of the function.

VARIABLE-NOT-SPECIAL

Undo the global special declaration. This returns a new symbol with the same name, package, fdefinition, and plist as the argument. This can be confused by imported symbols. Also, (FUNCTION-LAMBDA-EXPRESSION (FDEFINITION NEW)) will return the OLD (uninterned!) symbol as its 3rd value. BEWARE!

VARIABLE-SPECIAL-P

Return T if the symbol names a global special variable.

GETENV

Set an environment variable.

GETENV

Return the value of the environment variable.

DEFAULT-DIRECTORY

The default directory.

WITH-OPEN-PIPE

Open the pipe, do something, then close it.

CLOSE-PIPE

Close the pipe stream.

PIPE-INPUT

Return an input stream from which the command output will be read.

PIPE-OUTPUT

Return an output stream which will go to the command.

RUN-PROG

Common interface to shell. Does not return anything useful.

NOT-IMPLEMENTED

Your implementation does not support this functionality.

CODE

An error in the user code.

MK-ARR

Make array with elements of TYPE, initializing.

COMPOSE

DEFCONST

Define a typed constant.

Acknowledgements

To the CL Gardeners project (now defunct) which suggested this activity. To:

bordeaux-threads (threading)

usocket (sockets)

CLOCC's obsolete PORT

trivial gray streams

trivial garbage closer-mop

cl-fad (pathnames)

for obsoleting most of CLOCC PORT.

Toplevel Macros in Alexandria: Code Revival Project
posted on 2019-04-29

After finding the old CL Gardeners' site (now defunct), I thought I'd carry the torch this afternoon. They have four suggestions for "gardening" Common Lisp:

  • Consumer reports: Write a comparison of different libraries that do the same or similar things. Summarize the strengths and weaknesses of each. Include "under the hood" assessment; would I want to maintain this if the author got hit by a bus?
  • Code revival: Adopt an abandoned library and clean up the bit rot.
  • Code mining: dig through existing open source code bases of large applications and extract bits that can be packaged as a useful stand-alone libraries.
  • Implementation convergence: help bring various CL implementations into alignment where there's no good reason for them to differ. This can be done by providing portability libraries or, better yet, by doing the decidedly non-trivial work of finding a common ground that different implementers can actually agree on and then doing whatever it takes to convince them to make the necessary changes to their implementation. ("Whatever it takes" in this case, likely includes patches, test suites, documentation, and civil, egoless, participation in relevant developer forums.)

Browsing the site on the web archive (since they have been defunct for ten years), I found a todo item.

John Connors proposes to revivive the Port module from the
[CLOCC](http://clocc.sourceforge.net/dist/port.html): it was a small module that
provides portable acess to filesystems, threads and sockets.

I was excited to see that two of the functions in ext.lisp were already in my uitility library (as version spontaneously written by me), so clearly they deserved to be revived!

Cleaned them up and submitted to alexandria.

CSV
posted on 2019-01-07

Defines a lisp reader to read is CSV:

#!"field","field","field"!#

which is used to read in CSV files with slurp:

(slurp #p"example.csv")

and the result is a list:

CL-USER> (csv:slurp #p"example.csv")
("example" "csv" "list" "result" "like" " this")

This program invokes the lisp reader, making it:

1) Potentially risky to use if the input it not trusted.

2) Resource intensive for medium to large files (>5MB).

Use with care.

Features:

Supports escaping quotes the CSV way, with quad quotes:

csv -> lisp

"""" -> "\""

Installation

Clone from github into asdf load directory and use ASDF to install:

$ git clone https://github.com/equwal/CSV
$ sbcl
CL-USER> (asdf:load-system :csv)
T

Notes:

By default backslashes are not escaped. CSV is expected to be a list of quoted items, like this:

#!"example","here"!#

How to Beat Emacs M-x dunnet in 5 minutes.
posted on 2018-12-29

What?

In the emacs text editor there are some goofy commands that play games. M-x (which means Alt+x) is the way to execute a command in the editor, so M-x dunnet starts the game called "dunnet" which is a text adventure. I cheated and won. Defining just one function and setting one variable is sufficient to win. Here is a text map of the easy path. The command prompt is a >.

Basic Commands

  • >take something
  • >look
  • >save path
  • >restore path
  • Directions Are: n,s,e,w,ne,se,nw,sw,u,d,in,out (so you might go n).

To win

First, save the game so you can restart easily later:

  • >save ~/fresh.dun

How you need to move around the world a bit. Dunnet will greet you:

You are at a dead end of a dirt road.  The road goes to the east.
In the distance you can see that it will eventually fork off.  The
trees here are very tall royal palms, and they are spaced equidistant
from each other.
There is a shovel here.
  • >take shovel
  • >go e
  • >go e
  • >dig
  • >look
  • >take cpu
  • >go se
  • >take food
  • >go se
  • >feed bear food
  • >look
  • >take key
  • >go nw
  • >go nw
  • >go ne
  • >go ne
  • >go ne
  • >go w
  • >put cpu in computer

Now in M-: you must login to the VAX console

  • Eval: (setq dun-logged-in t)

back to the dungeon:

  • >type

greeted by a $ prompt:

To get to endgame in the VAX console, define this with M-:

(defun dun-score (garb) 90)

Now back to the dungeon:

  • $ rlogin endgame

  • >go n

Congrats, now you get questions, here they all are with answers:

  • What is your password on the machine called 'pokey'? robert
  • What password did you use during anonymous ftp to gamma? foo
  • Excluding the endgame, how many places are there where you can put treasures for points? 4 or four
  • What is your login name on the 'endgame' machine? toukmond
  • What is the nearest whole dollar to the price of the shovel? 20 or twenty
  • What is the name of the bus company serving the town? mobytours
  • Give either of the two last names in the mailroom, other than your own. collier
  • What cartoon character is on the towel? snoopy
  • What is the last name of the author of EMACS? stallman
  • How many megabytes of memory is on the CPU board for the Vax? 2
  • Which street in town is named after a U.S. state? vermont
  • How many pounds did the weight weigh? ten
  • Name the STREET which runs right over the subway stop. 4th
  • How many corners are there in town (excluding the one with the Post Office)? 24
  • What type of bear was hiding your key? grizzly
  • Name either of the two objects you found by digging. cpu
  • What network protocol is used between pokey and gamma? ip

So you might do:

  • >answer cpu

then:

  • >go n

there are three quesions in total:

  • >answer something
  • >go n
  • >answer something
  • >take bill

(naturally, you deserve it you cheater)!

  • >go n
  • >take Mona

(you dirty cheater)

Congrats you are in the winner's room.

  • >save ~/cheater.dun
  • >restore ~/fresh.dun

Now you can actually play it if you want.

Brazil
posted on 2018-11-26
California
posted on 2018-11-21
Org Mode Support With Coleslaw
posted on 2018-02-01

Coleslaw

Coleslaw is a static content generator, similar to Jekyll or Wordpress, written in Common Lisp. It supports Markdown, cl-who, and some other formats. I have written a very hacky org-mode format implementation that uses undocumented internals. Unfortunantly the only alternative is to require that everything is done from within Emacs by a user, instead of being able submit from the Common Lisp REPL. Hopefully I can petition to get the one function made external and supported, but otherwise you can expect this code to maybe randomly break in the future.

How it works

Just write a regular org-mode file, without any coleslaw headers. Everything is done via org, so use org headers like #+TITLE for metadata.

TODO

  • Tagging integration with coleslaw (so RSS feeds work, for example).

This blog covers article

View content from 2018-02, 2018-11, 2018-12, 2019-01, 2019-04, 2019-4-


Spenser Truex
Contact
hacker emblem