io

Patrick Stein: Ray Tracing In One Weekend (in Lisp, and n-dimenions)

Earlier this year, I started working through the online book Ray Tracing In One Weekend (Book 1). I have been following along with it in Common Lisp, and I have been extending it all from 3-dimensional to n-dimensional.

I reproduced 4-dimensional versions of all of the book images which you can see on my weekend-raytracer github page.

Here is the final image. This is a 250-samples-per-pixel, 640x360x10 image plane of three large hyperspheres (one mirrored, one diffuse, one glass) atop a very large, diffuse hypersphere. Also atop this very large hypersphere are a bunch of smaller hyperspheres of varying colors and materials. The image is rendered with some defocus-blur.

Final image of 4-dimensional scene

Caveat: This depends on a patched version of the policy-cond library that is not in the current Quicklisp distribution but should be in the next.




io

vindarel: Running my 4th Common Lisp script in production© - you can do it too

Last week I finished a new service written in Common Lisp. It now runs in production© every mornings, and it expands the set of services I offer to clients.

It’s the 4th service of this kind that I developed: - they are not big - but have to be done nonetheless, and the quicker the better (they each amount to 1k to 2k lines of Lisp code), - they are not part of a super advanced domain that requires Common Lisp superpowers - I am the one who benefits from CL during development, - I could have written them in Python - and conversely nothing prevented me from writing them in Common Lisp.

So here lies the goal of this post: illustrate that you don’t need to need a super difficult problem to use Common Lisp. This has been asked many times, directly to me or on social media :)

At the same time, I want to encourage you to write a little something about how you use Common Lisp in the real world. Sharing creates emulation. Do it! If you don’t have a blog you can simply write in a new GitHub repository or in a Gist and come share on /r/lisp. We don’t care. Thanks <3

We’ll briefly see what my scripts do, what libraries I use, how I deploy them, what I did along the way.

Needless to say that I dogfooded my CIEL (beta) meta-library and scripting tool for all those projects.

Table of Contents

Scripts n°4 and 2 - shaping and sending data - when you can write Lisp on the side

My latest script needs to read data from a DB, format what’s necessary according to specifications, and send the result by SFTP.

In this case I read a DB that I own, created by a software that I develop and host. So I could have developed this script in the software itself, right? I could have, but I would have been tied to the main project’s versioning scheme, quirks, and deployment. I rather had to write this script on the side. And since it can be done on the side, it can be done in Common Lisp.

I have to extract products and their data (price, VAT...), aggregate the numbers for each day, write this to a file, according to a specification.

To read the DB, I used cl-dbi. I didn’t format the SQL with SxQL this time like in my web apps (where I use the Mito light ORM), but I wrote SQL directly. I’m spoiled by the Django ORM (which has its idiosyncrasies and shortcomings), so I double checked the different kinds of JOINs and all went well.

I had to group rows by some properties, so it was a great time to use serapeum:assort. I left you an example here: https://dev.to/vindarel/common-lisps-group-by-is-serapeumassort-32ma

Dates have to be handled in different formats. I used local-time of course, and I still greatly appreciate its lispy formatter syntax:

(defun date-yymmddhhnnss (&optional date stream)
  (local-time:format-timestring stream
                                (or date (local-time:now))
                                :format
                                '((:year 4)
                                  (:month 2)
                                  (:day 2)
                                  (:hour 2)
                                  (:min 2)
                                  (:sec 2)
                                  )))

the 2 in (:month 2) is to ensure the month is written with 2 digits.

Once the file is written, I have to send it to a SFTP server, with the client’s codes.

I wrote a profile class to encapsulate the client’s data as well as some functions to read the credentials from either environment variables, the file system, or a lisp variable. I had a top-level profile object for ease of testing, but I made sure that my functions formatting or sending data required a profile parameter.

(defun send-stock (profile &key date) ...)
(defun write-stock (profile filename) ...)

Still nothing surprising, but it’s tempting to only use global parameters for a one-off script. Except the program grows and you pay the mess later.

SFTP

To send the result through SFTP, I had to make a choice. The SFTP command line doesn’t make it possible to give a password as argument (or via an environment variable, etc). So I use lftp (in Debian repositories) that allows to do that. In the end, we format a command like this:

lftp sftp://user:****@host  -e "CD I/; put local-file.name; bye"

You can format the command string and run it with uiop:run-program: no problem, but I took the opportunity to release another utility:

First, you create a profile object. This one-liner reads the credentials from a lispy file:

(defvar profile (make-profile-from-plist (uiop:read-file-form "CREDS.lisp-expr"))

then you define the commands you’ll want to run:

(defvar command (put :cd "I/" :local-filename "data.csv"))
;; #<PUT cd: "I/", filename: "data.csv" {1007153883}>

and finally you call the run method on a profile and a command. Tada.

Deploying

Build a binary the classic way (it’s all on the Cookbook), send it to your server, run it.

(during a testing phase I have deployed “as a script”, from sources, which is a bit quicker to pull changes and try again on the server)

Set up a CRON job.

No Python virtual env to activate in the CRON environment...

Add command line arguments the easy way or with the library of your choice (I like Clingon).

Script n°2 and simple FTP

My script #2 at the time was similar and simpler. I extract the same products but only take their quantities, and I assemble lines like

EXTRACTION STOCK DU 11/04/2008
....978202019116600010000001387
....978270730656200040000000991

For this service, we have to send the file to a simple FTP server.

We have a pure Lisp library for FTP (and not SFTP) which works very well, cl-ftp.

It’s a typical example of an old library that didn’t receive any update in years and so that looks abandoned, that has seldom documentation but whose usage is easy to infer, and that does its job as requested.

For example we do this to send a file:

(ftp:with-ftp-connection (conn :hostname hostname
                                   :username username
                                   :password password
                                   :passive-ftp-p t)
      (ftp:store-file conn local-filename filename))

I left you notes about cl-ftp and my SFTP wrapper here:

Scripts n°3 and n°1 - specialized web apps

A recent web app that I’m testing with a couple clients extends an existing stock management system.

This one also was done in order to avoid a Python monolith. I still needed additions in the Python main software, but this little app can be independent and grow on its own. The app maintains its state and communicates it with a REST API.

 

It gives a web interface to their clients (so my clients’ clients, but not all of them, only the institutional) so that they can:

  • search for products
  • add them in shopping carts
  • validate the cart, which sends the data to the main software and notifies the owner, who will work on them.

The peculiarities of this app are that:

  • there is no user login, we use unique URLs with UUIDs in the form: http://command.client.com/admin-E9DFOO82-R2D2-007/list?id=1
  • I need a bit of file persistence but I didn’t want the rigidity of a database so I am using the clache library. Here also, not a great activity, but it works©. I persist lists and hash-tables. Now that the needs grow and the original scope doesn’t cut it any more, I wonder how long I’ll survive without a DB. Only for its short SQL queries VS lisp code to filter data.

I deploy a self-contained binary: code + html templates in the same binary (+ the implementation, the web server, the debugger...), with Systemd.

I wrote more on how to ship a standalone binary with templates and static assets with Djula templates here:

I can connect to the running app with a Swank server to check and set parameters, which is super helpful and harmless.

It is possible to reload the whole app from within itself and I did it with no hiccups for a couple years, but it isn’t necessary the most reliable, easiest to set up and fastest method. You can do it, but nobody forces you to do this because you are running CL in production. You can use the industry’s boring and best practices too. Common Lisp doesn’t inforce a “big ball of mud” approach. Develop locally, use Git, use a CI, deploy a binary...

Every thing that I learned I documented it along the way in the Cookbook ;)

Another app that I’ll mention but about which I also wrote earlier is my first web app. This one is open-source. It still runs :)

 

In this project I had my friend and colleague contribute five lines of Lisp code to add a theme switcher in the backend that would help him do the frontend. He had never written a line of Lisp before. Of course, he did so by looking at my existing code to learn the existing functions at hand, and he could do it because the project was easy to install and run.

(defun get-template(template &optional (theme *theme*))
  "Loads template from the base templates directory or from the given theme templates directory if it exists."
  (if (and (str:non-blank-string-p theme)
           (probe-file (asdf:system-relative-pathname "abstock" (str:concat "src/templates/themes/" theme "/" template))))
      ;; then
      (str:concat "themes/" theme "/" template)
      ;; else :D
      template))

He had to annotate the if branches :] This passed the code review.

Lasting words

The 5th script/app is already on the way, and the next ones are awaiting that I open their .docx specification files. This one was a bit harder but the Lisp side was done sucessfully with the efficient collaboration of another freelance lisper (Kevin to not name him).

All those tasks (read a DB, transform data...) are very mundane.

They are everywhere. They don’t always need supercharged web framework or integrations.

You have plenty of opportunities to make yourself a favor, and use Common Lisp in the wild. Not counting the super-advanced domains where Lisp excels at ;)


Links

I have done some preliminary Common Lisp exploration prior to this course but had a lot of questions regarding practical use and development workflows. This course was amazing for this! I learned a lot of useful techniques for actually writing the code in Emacs, as well as conversational explanations of concepts that had previously confused me in text-heavy resources. Please keep up the good work and continue with this line of topics, it is well worth the price! [Preston, October of 2024]




io

All Souls Night (Conclusion)

.

 


 


 


 


 

FINIS

 

Above: Every Autumn, I write a Halloween story, write it out on leaves (one word per leaf), photograph the leaves, and then leave them where I found them. The story is then serialized, starting on October 1 and concluding on the 31st--All Souls Day.

 

*

 

 




io

ALL SOULS NIGHT Complete! In One Easy-to-Read Location!

.


This year's Halloween story, written on leaves and serialized daily on my blog, one sentence at a time, is done. Every day in October, I added to it, it reached its last words on Halloween.

Funny thing, though. In conversations with two different friends, I learned that neither of them had realized it was a story. They each thought I was just posting random sentences written on leaves. One of them is an artist, and thinks primarily in visual terms, so I thought at first that was a misunderstanding curious to her. The other, however, is a well-known writer and, what's more important, quite a good one. I have no idea what's going on there.

Long story short, at my behest, my son Sean, put all the photos up on Imgur, subtitled. So, if you didn't realize that they told a story... Or if, somehow, you weren't able to hold all the sentences in your head until the story was complete... Now you can find out what was going on. (The stone angels mark the ends of paragraphs.)

You can find it by clicking on the link here.


*





io

Popular destinations in Sweden

Popular destinations in Sweden



View Comic!







io

Estonia 039 s National Animal

Estonia 039 s National Animal



View Comic!









io

Eight injured in explosion at oil refinery in UP's Mathura - ANI News

  1. Eight injured in explosion at oil refinery in UP's Mathura  ANI News
  2. 8 injured, three critical in major explosion at Indian Oil plant in UP's Mathura  India Today
  3. Eight injured in fire at IndianOil’s Mathura refinery  BusinessLine
  4. Mathura refinery blast: Indian Oil refinery explosion injures 12 people  The Financial Express
  5. At least 8 injured in explosion at Mathura refinery  The Indian Express




io

21 million bitcoins

Today on Married To The Sea: 21 million bitcoins


This RSS feed is brought to you by Drew and Natalie's podcast Garbage Brain University. Our new series Everything Is Real explores the world of cryptids, aliens, quantum physics, the occult, and more. If you use this RSS feed, please consider supporting us by becoming a patron. Patronage includes membership to our private Discord server and other bonus material non-patrons never see!




io

congratulations borned

Today on Married To The Sea: congratulations borned


This RSS feed is brought to you by Drew and Natalie's podcast Garbage Brain University. Our new series Everything Is Real explores the world of cryptids, aliens, quantum physics, the occult, and more. If you use this RSS feed, please consider supporting us by becoming a patron. Patronage includes membership to our private Discord server and other bonus material non-patrons never see!




io

dont show me your damn emotions

Today on Married To The Sea: dont show me your damn emotions


This RSS feed is brought to you by Drew and Natalie's podcast Garbage Brain University. Our new series Everything Is Real explores the world of cryptids, aliens, quantum physics, the occult, and more. If you use this RSS feed, please consider supporting us by becoming a patron. Patronage includes membership to our private Discord server and other bonus material non-patrons never see!




io

what kind of vision

Today on Married To The Sea: what kind of vision


This RSS feed is brought to you by Drew and Natalie's podcast Garbage Brain University. Our new series Everything Is Real explores the world of cryptids, aliens, quantum physics, the occult, and more. If you use this RSS feed, please consider supporting us by becoming a patron. Patronage includes membership to our private Discord server and other bonus material non-patrons never see!




io

ive found a prescription

Today on Married To The Sea: ive found a prescription


This RSS feed is brought to you by Drew and Natalie's podcast Garbage Brain University. Our new series Everything Is Real explores the world of cryptids, aliens, quantum physics, the occult, and more. If you use this RSS feed, please consider supporting us by becoming a patron. Patronage includes membership to our private Discord server and other bonus material non-patrons never see!







io

The Built-In Air Conditioning Just Wasn't Effective

Especially after someone put that giant wooden thing on top.




io

A Warriors Dozen

UK not-for-profit Eggs for Soldiers built a life-size tank out of 5,000 cartons to help raise awareness for its upcoming March Fourth Help for Heroes Campaign.

[youtube=http://www.youtube.com/watch?feature=player_embedded&v=40PXCVBEwAQ&w=500&showinfo=0]




io

USC football placed on 1 year of probation, fined for coaching staff violations

Southern California’s football program has been fined $50,000 and placed on probation for one year by the NCAA because of multiple violations of coaching staff rules over two seasons




io

Joey Logano 1-on-1: Winning Cup Series championship is 'electric'

Joey Logano sat down with FOX Sports to discuss the wild pace-car wreck, the playoff format and the feeling of winning the title at Phoenix.




io

49ers agree to 5-year, $92 million extension with CB Deommodore Lenoir

San Francisco 49ers cornerback Deommodore Lenoir has agreed to a five-year, $92 million extension to stay with the team instead of testing the free agent market next offseason




io

Deion Sanders talks Shedeur Sanders’ growth from last year to this season | Speak

Deion Sanders discusses the impressive growth of Shedeur Sanders from last season to this year, highlighting his development as Colorado’s QB and the strides he’s made on the field.




io

Deion Sanders compares Shedeur and Travis’ chemistry to Michael Irvin and Troy Aikman | Speak

Deion Sanders talks about the strong chemistry between Shedeur Sanders and Travis Hunter, comparing it to the connection Michael Irvin had with Troy Aikman during their playing days.




io

Deion Sanders argues why Travis Hunter is a Heisman front-runner this year | Speak

Deion Sanders argues why Travis Hunter is a top contender for the Heisman this year, highlighting his unique talent and impact on Colorado’s success.




io

Mavs' Klay Thompson cheered by 400 Warriors employees in return to Golden State

Klay Thompson was greeted by some 400 cheering Warriors employees showing their love and appreciation for the former Golden State star and lined up along his path to the Dallas locker room




io

Michael Irvin asked Deion Sanders about coaching the Cowboys | Speak

Michael Irvin asks Deion Sanders about the possibility of coaching the Dallas Cowboys, sparking a funny moment and laughter.




io

College Football Playoff Rankings: Oregon, Ohio State on top; Alabama enters top 10

The second set of College Football Playoff Predictions were released Tuesday night, with Oregon, Ohio State and Texas listed in the top three spots. See the complete rankings!




io

Deion Sanders says he’ll intervene if ‘wrong' NFL team tries to draft son Shedeur

Coach Prime tells the "Speak" crew how he plans to handle the NFL draft process with quarterback son, Shedeur, and two-way star Travis Hunter.




io

2024-25 NBA championship odds: Celtics, Thunder favored; Cavs rising

A number of contenders are chasing the defending champion Celtics on the oddsboard. Check out where things stand, with insight from Jason McIntyre.




io

Champions Classic: Hunter Dickinson leads Kansas past MSU; Kentucky rallies past Duke

Hunter Dickson led No. 1 Kansas to an impressive win over Michigan State, while Mark Pope aced his first big test as Kentucky's head coach.




io

graduation

I'm in the US at the moment, where two of my nephews have recently finished (mostly now AmE in this sense) high school. That is to say, they (AmE) graduated from high school. Though their graduation ceremonies were in June, they are still in the midst of graduation party season—and we arrived in time to attend one of those parties. Invitations are extended to extended family, family friends, the graduate's classmates/friends and their nuclear families. And all family units who attend will bring a gift for the graduate. Back when I graduated, these were mostly presents you could unwrap. Dictionaries were common graduation gifts, and I recall getting a  cookbook (orig. more AmE, vs BrE cookery book) and things for my (AmE) dorm room. I also got two handmade dolls, meant to represent me as a graduate—and since I'm at my childhood home, you get to see them. They're looking pretty good at 41 years old.

These days, graduation presents mostly come in envelopes. My first stop on this US trip was at the bank, to get some crisp (AmE) bills/(BrE) banknotes to slip into cards for the two nephews as well my niece, who has a freshly minted BSc in Economics. (If you've read The Prodigal Tongue, you've met her before. She was the niece who had things to say about British bacon.) 

High school graduation parties are generally not held in England—partly because there one does not graduate from high school. Graduation is only for those who get a degree from a university. But even when people graduate with a degree, family parties like this are not common. Generally, Americans do a lot more of this kind of party-throwing and gift-giving to mark life transitions (and help out a bit). See the earlier post about showers

Meanwhile, my 16-year-old (aka Grover) has recently finished secondary school in England. (Her secondary school, as it happens and unusually for England, has high school in its name.) Before school finished, she took 27 exams over 6 weeks in 9 subjects—this is what's known as the GCSEs (General Certificate[s] of Secondary Education). (NB: Many of the educational issues that come up here have been described in previous blog posts—rather than clicking on each link here, you might want to save your efforts for the 'related posts' links below.) Grover won't know her results in those exams till late August, when she'll be able to enrol(l) in the sixth-form college that's accepted her. (Though she's accepted to the college, she won't know until she has her exam results whether she's met the prerequisites for the A-level subjects she's chosen.) 

Her status has been difficult to explain to her American family. Sixth-form college is not what Americans think of as college, which would be called university in BrE. In England, sixth-form (and many other diverse things!) counts as further education—after secondary school, but not degree-level study. In an effort to translate her status, she's started telling Americans that she's graduated. Her reasoning for this is that (a) they had a little ceremony in an assembly on their last day of school, (b) she's going to something called college, and (c) she's had a prom (an imitation of the American tradition for these younger students). But since she doesn't even know whether she's passed her exams,* it can't really be counted as "graduating", can it? I have suggested to her that she may be misrepresenting her situation. She doesn't mind. It might yet pay off...



What she is, in Britain, is a school leaver. Instead of getting a mortar board and gown, she got a (orig. BrE) hoodie. (Pic here from an Etsy shop. Grover's hoodie is back in Brighton.)


*Oh, I'm sure she's passed. Whether she's got the prerequisite grades is another matter, so it's all a bit stressful. 




PS: While on this holiday, I have missed the University of Sussex graduation. I usually go, but since Grover's school ended early this year, we took advantage of being able to travel before the prices go insane during the (BrE) school holidays. (As Paul in the comments section notes, GCSE students just stop going to school after their last exam—it's very anticlimatic, but it got G out of school about a month earlier than usual. We hung around for the prom in early July.)

So, I want to say: Congratulations to our BA English Language and Linguistics and BA English Language and Literature graduates of 2024! Here's the outfit you didn't get to see me wear.

Related posts:

Types of schools and school years 
(the one that's linked-to a LOT above!)

2021 UK-to-US Word of the Year: university

Academic titles and address

And lots of others with the Education label





io

WHAT I SEE IN MY PRESCRIPTION

WHAT I SEE IN MY PRESCRIPTION





io

What’s Wrong With Today’s Society Captured In 20 Brutally Honest Illustrations

This illustrator, John Holcroft, is genius! check out his website for more.

 




io

12 Comics That Put Gender Discrimination Into Perspective







io

Top Memes And Reactions To Last Night's Democratic Presidential Debate

Why do politics always make for the best meme material? We'll just let the politicians speak for themselves. 

In case you missed last night's democratic presidential debate, then we'll give you a little run down: Cory Booker accused Joe Biden of being high, Amy Klobuchar claimed she raised a crap-load of money from her ex-boyfriends, and Biden made an, uh, brain-dead comment about domestic violence. 

Scroll down to watch some of the highlights and view some of the internet's reactions!




io

Twitter Roasts Pete Buttigieg For His Staged 'Walk Back To Iowa'

Poor Mayor Pete just can't seem to catch a break on the internet. The presidential candidate from South Bend, Indiana tweeted a photo of himself walking down a hallway on Saturday with the caption, "On my way back to Iowa. It's phase 4. Let's do this." The tweet has been catching a fair amount of flack for appearing to be staged. 

Here are some of Twitter's most amusing reaction memes and tweets!




io

Iowa Caucus's Delayed Results Have Churned Up Some Anxious Reaction Memes

Last night the 2020 Iowa Democratic Caucus stirred up quite the controversy when it was announced that the results would be delayed due to "inconsistencies" in a new app meant to speed up the reporting results of the caucus. Ironic, to say the least. 

But hang tight, because they're set to be released at 5 pm Eastern Time.

Ahead of the results being released, Pete Buttigieg gave what appeared to be a victory speech last night to the confusion of many. The bizarre move has lead many to believe that the system may have been rigged in Mayor Pete's favor.

As always, we have to give the disclaimer that we're not picking sides; we're merely reporting on what the internet has been saying, so scroll down to see some of our favorite reaction memes and tweets while we all wait impatiently for the results.




io

The Shadow Team Gets Roasted For Being Shady During The Iowa Caucus

Meet the Shadow team in charge of developing an app meant to help tally the votes from the Iowa caucus on Monday night. The purpose of the app was to help the process run more smoothly, but in the end it proved to be a complete and utter disaster, as precinct chairs supposedly couldn't get the app to actually work, in turn causing a delay in reporting.

The delay was blamed on "inconsistencies" in reporting, but honestly, who really knows what the truth is.

The team is reportedly run by people who worked on Hilary Clinton's presidential campaign in 2016. Additionally, 2020 candidate Pete Buttigieg's campaign paid the tech firm over $40,000 in 2019 leading many to suspect foul play.

But this is America, and we can't possibly have problems with corruption, right?

As of right now, we still don't have all the results from the caucus, so while you continue to anxiously refresh the New York Times page, have some hot Twitter takes on the people (rats) behind Shadow, Inc.




io

Michael Bloomberg Memes That Roast The Cringey Billionaire

You're probably already aware that Michael Bloomberg, cringey billionaire extraordinaire and 2020 presidential candidate, has been reaching out to various big-name meme accounts on Instagram asking them to post content that makes him look a little more...hip to the kids, shall we say? 

But apparently he's doing something right with his presidential campaign, as he's been soaring in the polls and we're seeing ads for him practically everywhere.

Normally we don't like to get too political, but it's clear that Bloomberg was not hugged enough as a child.




io

'Today Years Old' Revelations That Might Teach Something New

The saying "you learn something new every day" may not always feel true, but on Twitter, that's definitely the case. People are very eager to share surprising and little-known facts that blow their minds - whether they're political or about something as trivial as the flavor of green Haribo gummy bears. These facts might not be revelatory for everyone, but they definitely aren't common knowledge. And it's nice to make that brain feel a little bigger. 




io

Fresh History Memes Sprinkled With Educational Spice

While it's said that history is always doomed to repeat itself, it's definitely anything but boring. These fresh (and spicy) history memes take the stuff of dull classes and actually spin it into something funny. Lord knows you'll probably learn more from these funny pictures than you will from a Zoom class.




io

How tech giants have been getting away with Age Discrimination

Corporate diversity initiatives have focused primarily on skin color, ethnicity, and gender thus far, but age should also be imperative.  Aside from it being an overlooked and unmonitored protected category, workforce demographics project a talent shortage for all diversity groups under 40. In the coming months, IBM could face hundreds of lawsuits (and/or a class […]

The post How tech giants have been getting away with Age Discrimination appeared first on DiversityJobs.com.




io

NFPA offers free 1st Responder Connection App

The National Fire Protection Association (NFPA) has released a free 1st Responder Connection App offering firefighters, EMS, command staff, public educators, wildland fire personnel, and authorities having jurisdiction (AHJs) convenient, digital access to best practices, safety tips, and emergency response content.