How to edit remote files within Emacs when a program automatically runs after you SSH

If you are used to TRAMP functionality of Emacs to edit remote files without leaving the comfort of your beloved editor on your host machine, you do your best to keep it working even when different conditions arise. In my case, I’ve been recently working with virtual machines at work and the product that I’m working on is configured to run some program automatically right after I log into the machine via SSH. This prevents TRAMP functioning correctly with its default settings, because instead of receiving the shell prompt immediately, it receives from the machine the final line of the program that automatically runs and expects the user enter some response:

    ... some text menu options ...
    Please make a selection >>

Above that line, the text menu says that the user should enter 0 to exit the program or some other menu option to continue. Therefore, I had to find a way to tell Emacs that it had to send a 0 after it connects to the machine. The high-quality TRAMP manual was immediately helpful by providing a relevant example and I came up with the following: Read the rest of this entry »

Leave a comment

Posted by on November 30, 2015 in Emacs, Lisp, Programlama


Tags: , , ,

How to detect Friday the 13th with full moon using Emacs

nrAlmost 21 years ago, in 1994, I bought the brand new edition of Numerical Recipes in C: The Art of Scientific Computing. As an engineering and mathematics student who was much into programming, I still remember my excitement then, as well as the bright red hard-cover.

The first algorithm presented in the book (and its implementation in C programming language) was about calculating the dates that were Friday the 13th and had full moon. Now that I’m approaching the 21st anniversary of that day, I wanted to share a similar program to detect if the current date is Friday the 13th with full moon. This time, my preference is for Emacs Lisp, and instead of re-implementing the same algorithm, I simply use the calculations already provided by Emacs. In other words, I rely on the lunar-phase-list function that returns the lunar phases of the upcoming dates given a month and a year.

It’s been ages since I’ve done Common Lisp programming and many years since I’ve practiced Emacs Lisp, so the code below is probably not optimal and idiomatic, but nevertheless it follows:

You can used the function defined above to see whether it is your “unlucky” day:

This will return “Good luck!” most of the time, luckily! :)

Can you come up with other ways of detecting Friday the 13th with full moon using existing utilities, such as GNU calendar program? Or, how would you calculate the next 10 Friday the 13ths that had full moon, using Emacs Lisp or some existing utility?


Leave a comment

Posted by on November 12, 2015 in Programlama, Emacs, Lisp


Tags: , ,

Do Great Minds Necessarily Need Fancy Technology to Collaborate?

We’re living in the age of touch enabled wireless devices that are connected to Internet almost always. We can have instant one-to-one video communication very easily and cheaply. It is possible to organize video teleconferences with many participants instantly (well, the last part might be a little exaggerated). Scientists and programmers separated from each other by thousands of kilometers and many time zones can work and collaborate on projects daily. It is almost natural to think that, without such technologies, we would be living in dark ages, and our greatest thinkers would suffer from isolation miserably. But is it really the case?

The following pages are from the chapter titled “Was Cantor Surprised?”, from a popular mathematics book, The Best Writing on Mathematics 2012:


Let’s focus on those particular sentences: Read the rest of this entry »

Leave a comment

Posted by on October 18, 2015 in General


How and Why is Scala Used in Aerospace Industry?

There’s been a recent thread in scala-user e-mail list that touched an interesting topic: How and Why is Scala Used in Aerospace Industry?

A few highlights from the thread:

* Scala and Akka are currently used for spacecraft telemetry data display, storage and analysis for European Space Agency. The software is used for all missions at GSOC (the Columbus Module of the ISS, the SAR earth observation satellites TerraSAR-X/TanDEM-X, and some other missions) and for LEOPs at Eutelsat.

* DLR GSOC ( ) will be using Scala and Spire for space mission planning. The next generation of the GSOC scheduling engine PLATO ( is currently being written in Scala.

* Scala is also used for telemetry analysis at JPL (NASA’s Jet Propulsion Laboratory), and more generally for development of modeling DSLs. We are part of a research lab (Laboratory for Reliable Software), which works in close interaction with missions.

* Rüdiger Klaehn’s words: “I am absolutely convinced that functional programming (meaning not just a language that has closures, but programming using almost exclusively with pure functions) is the correct path to reliable software. The most ubiquitous and accepted platform in space operations at DLR and in general in european space operations is the JVM. Even the next generation European Mission Control system (MCS) is going to be written for the JVM: So you need a functional language that runs on the JVM and can seamlessly consume JVM libraries. This leaves Scala and Clojure as serious contenders. Since I favour strongly typed languages, the choice was clear.”

Some reasons given by programmers that chose Scala for aerospace industry software: Read the rest of this entry »

1 Comment

Posted by on December 22, 2014 in FunctionalProgramming



How to fix class “javax.servlet.FilterRegistration”‘s signer information does not match signer information of other classes in the same package (when unit testing with Spark Streaming)

I’ve recently started to write some unit tests for a Spark Streaming application and even the simplest scenario led to the following error:

class “javax.servlet.FilterRegistration”‘s signer information does not match signer information of other classes in the same package

This happened when Maven ran the test, in other words, it was a run-time error. An Internet search indicated that I should be suspicious about different versions of javax.servlet. The following commands showed that I was on the right track:

mvn dependency:tree
mvn dependency:tree | grep servlet

Modifying the pom.xml for excluding javax.servlet as follows solved the problem:


I hope things will be less conflicting in the upcoming Hadoop and Spark versions.

Leave a comment

Posted by on December 4, 2014 in Programlama


Tags: , , ,

How to get better performance from Scala by using Parallel Collections

Today I needed to download the HTML content of some articles from a newspaper and I’ve decided to write a quick and dirty Scala application to get the job done quickly. I only needed to parse a main HTML page using regular expressions, get a list of URLs, and then iterate over them, by getting the contents of each, and finally writing them to files. Thanks to Scala I was able to code it comfortably and quickly, but when I ran the code I’ve seen that it took about 50 seconds to grab the contents of 150 URLs. Would it be possible to make it faster? Fortunately, Scala had Parallel Collections support for a very long time, and I’ve decided to try it out.

All I had to do was to convert the following part:

for (url <- urls) { ...


for (url <- urls.par) { ...

and run it again.

The result was better than I expected: The ‘normal’ version ran in the range of 30 to 50 seconds whereas the parallelized version run in the range of 8 – 10 seconds, that is 3 to 5 times faster! Yet another reason to use Scala.

And for those who say “Gist or didn’t happen”, you can see the source code at and its relevant build.sbt file at Don’t take my word for it, spend a few minutes and try it yourself.

Leave a comment

Posted by on October 31, 2014 in Programlama


Tags: ,

Functional Programming in Scala: The most advanced Scala and functional programming book for the working programmer

bjarnason_cover150It is safe to say that “Functional Programming in Scala” by Chiusano and Bjarnason can be considered the most advanced Scala programming book published so far (in a sense, it can be compared to SICP.). Half of one of my bookshelves is occupied by Scala books, including Scala in Depth, but none of them takes the concept of functional programming as serious as this book, and pushes it to its limits that much. This, in turn, means that most of the Java programmers (including very senior ones), as well as Scala programmers with some experience should prepare themselves to feel very much like a newbie again.

But why the need for such a book, and what’s all that noise about functional programming? Here is my favorite description of functional programming given by Tony Morris : “Supposing a program composed of parts A, B, C, D, and a requirement for program of parts A, B, C, and E. The effort required to construct this program should be proportional to the size of E. The extent to which this is true is the extent to which one achieves the central thesis of Functional Programming. Identifying independent program parts requires very rigorous cognitive discipline and correct concept formation. This can be very (very) difficult after exposure to sloppy thinking habits. Composable programs are easier to reason about. We may (confidentally) determine program behaviour by determining the behaviour of sub-programs -> fewer bugs. Composable programs scale indefinitely, by composing more and more sub-programs. There is no distinction between a ‘small’ and a ‘large’ application; only ‘smaller than’ or ‘greater than’.”

The description above not only points at the core idea of functional programming and why that is important, as well as useful, but also draws attention to the fact that getting used to functional programming design can be difficult for people who are not used to thinking that way. Fortunately, “Functional Programming in Scala” is here to fill a huge void in that respect.
Read the rest of this entry »

Leave a comment

Posted by on September 13, 2014 in FunctionalProgramming


Tags: ,


Get every new post delivered to your Inbox.

Join 66 other followers