The newLISP on Rockets blog

Yet another test poll

Post #: 96
Post type: Blog post
Date: 2013-03-25 16:49:44.000
Author: Rocket Man

How many roads must a man walk down?


This one features some text in here to try and see how that affects the formatting.

Poll Results:

Total votes: 92

one : 6......
two : 32..................................
three : 7.......
four : 11...........
forty-two : 36.......................................

Comments (16)

Views: 7176

This is another poll test - 2

Post #: 93
Post type: Blog post
Date: 2013-03-21 13:00:52.000
Author: Rocket Man

How many friggles in the flooby?



Poll Results:

Total votes: 48

one : 10....................
two : 16.................................
three : 9..................
four : 13...........................

Comments (6)

Views: 5480

How do I build a Forgot Password module? Here's how!

Post #: 88
Post type: Blog post
Date: 2013-03-06 17:18:44.000
Author: Rocket Man

I'd been putting off doing a Forgot Password module for newLISP on Rockets because it is such a pain doing it properly. You can't just have one click to reset a password, because what if someone else knows your user name or email? Then they could change your password to whatever they want!

So what most sites do is let you trigger a reset, then send a confirmation message to that email address, and then make you retrieve the email and click on a special link to reset your password.

Funnily enough, on another site I'm developing I was testing logging out and logging in, and you know what? I forgot my password. So I figured this was as good as an excuse as any to build a Forgot Module! (And no, I couldn't just grab the password from the database, because it's encrypted for security!)

I wanted the whole thing to be only a single page for simplicity. rockets-forgotpassword.lsp is the page that handles triggering the email, confirming and sending the email, and resetting the password, so the code flow may not seem obvious at first glance. The emails contain links of unique identifiers (sometimes called GUIDs) that expire after an hour and are matched with email addresses of the people who sent them, so people won't be able to guess them either. The tokens are stored in a file called reset-tokens.lisp. This file is automatically generated if it doesn't previously exist.

One more thing: to get the email links to work, the module needs two additional configuration options in Rockets-config.lisp:

(set 'AdminEmail "")

(set 'SiteURL "")

You should change these to your own email and URL from whatever domain you are running Rockets on.

The code, along with the rest of Rockets, is available in GitHub here:

Views: 5467

How to compile newLISP from source on 64-bit Ubuntu

Post #: 87
Post type: Blog post
Date: 2013-02-26 15:35:09.000
Author: Rocket Man

I've been wanting to update newLISP on my development box to see what neat new changes and features are available. Unfortunately, it's a 64-bit Ubuntu install, and pre-packaged binaries are only available for i386 (32-bit) on

So what to do? Well, compile from source of course!

First get the source:

cd ~
tar zxvf newlisp-10.4.5.tgz
cd newlisp-10.4.5

Now you're in the source code directory. First you need a few libraries, then you can go ahead and compile:

sudo apt-get install libffi-dev
sudo apt-get install libreadline6 libreadline6-dev
sudo make
sudo make install

And that's it! To get Rockets to work on Ubuntu, you'll have to go into the sqlite3.lsp module and add the appropriate path for where it lives on Ubuntu 64-bit:

cd /usr/share/newlisp/modules
sudo nano sqlite3.lsp

Add the following line under the list of similar lines:

"/usr/lib/x86_64-linux-gnu/" ; Ubuntu

Then do the same for crypto.lsp:

"/usr/lib/x86_64-linux-gnu/" ; Ubuntu

And you're good to go!

Comments (13)

Views: 7565

Converting other newLISP code to Rockets

Post #: 85
Post type: Blog post
Date: 2013-02-21 18:54:17.000
Author: Rocket Man

Today I relaunched my personal website at It had previously been running on Dragonfly, a web development framework that inspired me to write Rockets.

Converting the code was really easy. All it took was the following:

1. Replace all instances of (print) with (display) and (println) with (displayln)
2. Remove Dragonfly-specific functions like (web-root) that are no longer necessary.
3. Make sure to start each page with:

#!/usr/bin/env newlisp

(load "newlisp-rockets.lisp") ; this is where the magic happens!

and end each page with

(display-footer "Jeremy Reimer")

And that's pretty much it! So if you want to convert any Dragonfly code to Rockets, that's how you do it.

Comments (2)

Views: 6811

Refactoring Rockets

Post #: 84
Post type: Blog post
Date: 2013-02-15 11:59:24.000
Author: Rocket Man

I've made some changes to the code base that will make it easier to start new custom sites based on Rockets. This is for my benefit as well as everyone else's-- I'm currently developing a bunch of new sites with this technology!

Now, when you run setup-rockets.lisp, the script asks you for a long and short name for your blog, an owner name, and the database name. These are automatically saved in a new configuration file called Rockets-config.lisp. I went through every page in the Rockets blog and changed it so that it reads various custom data about the blog from the config file.

The config file looks like this:

(context 'RocketsConfig)
(set 'Database "ROCKETS-BLOG")
(set 'Name "The newLISP on Rockets Blog")
(set 'ShortName "newLISP on Rockets")
(set 'Owner "Rocket Man")
(context MAIN)

This should make it a lot easier to set up new sites with different configurations.

Comments (2)

Views: 5812

Adding custom Javascript or jQuery to your page in Rockets

Post #: 83
Post type: Blog post
Date: 2013-02-06 17:53:38.000
Author: Rocket Man

newLISP on Rockets comes with and works with jQuery, which lets you do all sorts of wild and wonderful things on your page. But where should you put your Javascript code?

It doesn't really matter where it goes as long as there are <script> tags around it, but sometimes you want to defer execution to the end of the page. This leads to the best performance, because the user isn't waiting for the Javascript to load before seeing the page elements.

I've modified (display-footer) to let you add a string of Javascript or jQuery code to your page and insert it right at the end. You assign the code to a string variable and then just call (display-footer "Your name" name-of-string-variable) and it will execute the Javascript or jQuery code at the end of the page.

Comments (2)

Views: 4679

Converting JSON data into a list

Post #: 81
Post type: Blog post
Date: 2013-01-30 16:28:47.000
Author: Rocket Man

JSON stands for the JavaScript Object Notation, and it's used by lots of applications because it's much more compact than the bulky XML format. It's also suspiciously similar to LISP lists, which isn't that surprising considering that JavaScript was originally written as a LISP interpreter.

The basic format is something like this:

"firstName": "John",
"lastName": "Smith",
"age": 25,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": 10021
"phoneNumber": [
"type": "home",
"number": "212 555-1234"
"type": "fax",
"number": "646 555-4567"

I've written a function in Rockets that converts this notation into a native newLISP list. Basically all I've done is replace { with ( and [ with (, then removed colons, commas, and other extraneous syntax. I ran into a small problem with very large text strings, because newLISP's internal list evaluator doesn't like them and returns a "string token too long" error. To fix this, I put [text] and [/text] in place of everything that had quotes, which tells newLISP's internal evaluator to treat it as a long string of text. Using (read-eval) I convert this long string of long strings back into a list, and all the [text] and [/text] goes away and you have a normal list!

The function is called (convert-json-to-list) and it's included in Rockets. I'm already finding it useful for my new project.

Comments (5)

Views: 5073

How to extract data from an RSS feed in Rockets

Post #: 80
Post type: Blog post
Date: 2013-01-25 14:12:04.000
Author: Rocket Man

RSS feeds are useful and great, but the XML structure they come in is rather unwieldy to read through and parse. newLISP has a great function called (parse-xml) that converts an XML tree into a list, but now you just have an unwieldy list. It's helpful to be able to extract only the data we want and put it in a simple nested list.

I've written a new function in Rockets that lets you do just that.

First, get the data from the RSS feed URL that you want:

(set 'feed-url "";))
(set 'rss-result (xml-parse (get-url feed-url)))

Now, we want to extract the fields "title", "author", and "link" from that feed.

(set 'field-result (get-fields-from-rss rss-result '("title" "author" "link")))

(field-result) will return the following:

(("News Post: The Book Of Divine Wisdom" " (Tycho)" "";)
("News Post: So many games!" " (Gabe)" "";)
...etc ... )

If a field isn't present in the RSS data, (field-result) will populate that part of the list with the "nil" value instead.

NOTE: Remove the spurious ";" characters in the example code here before running it

Happy RSSing!

Views: 4373

Copying Apache log files to a database

Post #: 79
Post type: Blog post
Date: 2013-02-15 10:57:40.000
Author: Rocket Man

Apache log files typically just sit around filling up your hard drive space, a vast array of text too unwieldy to search through.

A useful thing to do is to parse these files and copy them to a database. I've written a script that will do this using Rockets. It's not a web page-- it's a script that you should run from the command line (use sudo newlisp log-to-database.lsp) It will create a new database from scratch called SERVER-LOGS.db that you can then query and search using SQLite.

The script can be found here:

Note: I may be updating this later, as the database files seems quite large (only slightly smaller than the logs themselves)

Comments (1)

Views: 4373