A Hacker News Comment About Emacs

I have started using emacs a bit more lately. I spent a bit of time upgrading packages and getting CIDER to work. I would like to share a comment that was left by someone¬† going by “maehwasu” (perhaps a disciple of Deganawida) on Hacker News on August 26, 2015 (or whatever day was 818 days ago from today).

OP is getting hate, but I write a lot of Clojure code in Emacs, and I find the following commands cover 97%+ of my usage, maybe more. For config I use Emacs Live out-of-the-box, and remap Command on OSX to be my Ctrl. That’s it.

C-a, C-e, C-b, C-f, C-p, C-n, C-v, M-v for line/screen maneuvering.

C-o for Ace-jump to go to the start of any words I see on the page.

C-d to delete. C-s to search for words not on the page.

C-k, C-y, and also how to use them with paredit to yank whole s-expression chunks.

Buffer switching and killing.

File saving and opening.

I teach the above to any friends who want to learn Emacs/Clojure/LISP, leaving out a few other features like whole word deletion and more advanced paredit. With halfway decent aptitude and a little practice, they become productive very quickly (within a few hours, which is a pretty good investment relative to “normal” text editors in my book).

You’re welcome.

2017-11-19 Update

I am still looking at HugSQL. I started messing around with the quoting option in the connection macro. I noticed that I was not able to get any SQL injection samples to work through HugSQL. (It was a bit odd to try to intentionally do SQL injection after years of trying to prevent it.) I think the Postgres JDBC driver takes care of SQL injection.

To test this, I started looking at Migratus (and its leiningen plugin as well) to make a database in MySQL. I am more of a Postgres guy, so it took a while to get things right. Plus I think that Migratus has to do things a bit differently than regular SQL. I think that creating a table and creating a trigger for that table need to be two separate migrations.

I also had problems with foreign keys. With one foreign key, I got the table name wrong. I had to google the generic (and useless) error message. That led me to googling a few more steps. I had to log in as root, run the command

and look in that wall of text for a section labelled “LATEST FOREIGN KEY ERROR”.¬† The cause was buried in there. If MySQL is saving some text about the cause in this object, why can’t MySQL just print it out to the prompt instead of forcing me to go through all these other steps?

I might do a Migratus project with Postgres just to see if this small, irritating problem happens there too.

Another thing while working on all of this is I have used pg_dump a few times. I found a page online with examples that mostly work. Maybe I have Postgres configured differently, but I have found that for pg_dump, I have to add a few options to get it to work. The –help says that –password is unnecessary, that you should be prompted for it automatically. I have found that I need to add that, as well as –port and –host (even though I have been running it on localhost).

You’re welcome.

2017-11-12 Update

This weekend I planned on starting a Luminus app. But before too long I started looking at the database parts. This led me to look at HugSQL, based on a project outlined on a page hosted by a company called Compose.

I did a few things that are not in the article, incorporating a few more things I learned about HugSQL. I might add it to my Clojure app repo on Github in a few days.

Last week I mentioned I found a project that is a Clojure wrapper for Deeplearning4J. I did some searching on the Clojure subreddit, and I found a reference to a page about using Clojure on the Deeplearning4J website. Apparently there is an “official” port of Deeplearning4J to Clojure here. No offense to the other guy, but I think I will look at the official project first. I feel it is best to start with the official way of doing things before trying something unofficial. But it is always good to have options.

You’re welcome.

2017-11-06 Update

One thing I did this weekend was get permalinks working again on my blog. I got an SSL certificate from Let’s Encrypt several months ago, and I was not able to get permalinks to work. It bothered me for the longest time. Problem solved.

Not much on the Clojure API front.

I did look at Deeplearning4J, a deep learning framework written in Java. I cloned their repo of examples, and I got some of them working with gradle files, and learned a bit more about Gradle in the process. You can use a GPU, or a CPU. No messing with CUDA if you don’t want to.

There is even a Clojure wrapper for Deeplearning4J as well.

I had a post about using CPUs and GPUs from JVM languages for math/science/AI a while back. Since then, I have gotten both Neanderthal and Deeplearning4J to work on my system. I did mention Bytedeco, which is used by Deeplearning4J and a few other libraries. I looked at some of the Javadoc, and they use a LOT of static methods (see here for an example). I may leave Bytedeco for others and use some of the higher-level libraries, like Deeplearning4J. I think a lot of static methods is not idiomatic Java. I might consult “Effective Java” later for a second opinion.

I am going to include below one of the build.gradle files that I used to get some of the Deeplearning4J examples to work.

You’re welcome.

 

2017-10-29 Update

I worked a bit more on going through the Clojure functions. I might start working on a Clojure web app as well. (And start looking at TensorFlow too. Maybe.)

I also tried some of the scripts on the nftables wiki to move from iptables to nftables. I locked myself out and had to go to my host’s console to reboot the server. I guess copying and pasting will not work and I will have to figure this out the old school way.

You’re welcome.

2017-10-22 Update

There is not a whole lot to report this week. Not much progress on the Clojure front.

I did upgrade one of my laptops to the newest version of Ubuntu. I will use some of the updated packages to update my firewalls to nftables, although I have a feeling there will be more work that just running the scripts on the nftables website. This is part of completing my Groovy mail server.

Once I do that, I plan on running another mail server in another domain so I can send emails with TLS and not worry about getting banned. I hope mail-in-a-box is as easy as it sounds.

You’re welcome.

2017-10-01 Update

I am still going through Simply Scheme. I am on chapter 8.

I may also start going through the Clojure API. I have tried 4Clojure a few times, and I tried the Kotlin Koans. I don’t think that is a good way for me to learn. I have a Kotlin book that I am looking at. I have thought about going through the functions on the Clojure Cheat Sheet, but I would need some way to keep track of what I have done. I made a page with a list of the functions in the core Clojure API for version 1.8. I have thought about this for a while, but recently I found a page called “One Weird Trick To Become a Clojure Expert“, which advocates going through the API. I may not go alphabetically.

Plus, unlike the Kotlin API, the core Clojure API is small enough that you can actually get through it without feeling overwhelmed.

I also found out that lein and boot do not work with JDK 1.9 on Ubuntu. I gathered from web searches that Clojure 1.9 will solve the issue. It seems to work fine on Windows 10.

You’re welcome.

2017-09-24

This week I worked more on Simply Scheme. I got done with Chapter Six. Chapter Seven looks pretty short.

The Austin Clojure group had a code get-together at Cafe Express. There were only a few of us there. I worked on Simply Scheme.

One thing a lot of veteran Lisp/Scheme people do not like about Clojure is that it uses other characters for data structures (vectors, maps, sets) in places where other Lisps just use parentheses. I think I agree with Clojure for changing things a bit. I think it makes things more clear. There was a line about this topic in Chapter 7 of Simply Scheme that made me think about this:

Like cond, let uses parentheses both with the usual meaning (invoking a procedure) and to group sub-arguments that belong together.

There was a lot of discussion about JavaScript at the Clojure Meetup this weekend. I generally do not like anything related to JavaScript, not even ClojureScript. I have heard great things about it, and that David Nolen is a really smart guy, but it just seems like if you use ClojureScript, you will probably have to deal with a bunch of JavaScript anyway. So for now, I am not too eager to do anything mobile with Clojure. It seems like ReactNative still has a bad license, and you have to deal with Node on top of it all.

A couple of guys mentioned WebAssembly. I first read about that on the Racket mailing list in a thread in which a few people (myself included) were lamenting the inescapability of JavaScript. I think it is a drag that a lot of people want to use JavaScript everywhere. I would like an actual alternative (not just yet another *js framework, or a language that transpiles to JS). Will that be WebAssembly?

Someone on Hacker News somewhere warned that if a site uses WebAssembly, a site could prevent you from blocking ads if they really wanted to force you to see them. Stay tuned.

You’re welcome.

2017-09-17 Update

This week (and especially this weekend) were not too productive. I was hoping to look at some Clojure libraries for TensorFlow.

But I started out updating one of my laptops to Ubuntu 17, and I was unable to log in. So I downloaded Ubuntu Gnome and spent a lot of time trying to get that right. I hate hate hate the default Gnome window manager (I think it is called “mutter”). I tried to switch to another window manager, locked myself out, and then I tried to install Mint.

For some reason I was not able to burn the iso files, so I re-installed Ubuntu Gnome and figured out how to get compiz t work to make it somewhat usable.

I also thought about working on an nftables firewall, but there are some migration utilities that will be available in the next version of Ubuntu. I think the next version is coming out in a month.

You’re welcome.