Maoists in Limbo Article about the situation of Maoist revolutionaries in present day Nepal. I hope one of my favorite countries will soon be able to establish real peace!
China’s secure communications quantum leap Overview of China’s breakthrough in quantum communication. This could have interesting military implications (e.g. for submarines in the South China Sea), bet the PLA’s very happy.
Since my previous post on APL and J I’ve read the 45 or so pages of Easy J and am quite impressed by this nifty language. It may seem strange at first, but is very logically structured and not difficult to understand at all. That said I still need to constantly have the vocabulary open to write anything remotely useful, but I’m slowly starting to remember more and more of it.
Here are a couple of examples of J’s expressiveness, with the first two based on exercises from our “Core Ruby” course on RubyLearning.org.
How old is a person if he/she is 1 billion seconds old?
12
0 365 24 60 60 #: 1000000000
31 259 1 46 40
Using Antibase (#:) it’s easy to see that the answer is 31 years, 259 days, 1 hour, 46 minutes and 40 seconds.
Convert degress Fahrenheit to degrees Celsius.
123
toc =: %&1.8@-&32
toc 100
37.7778
Divide by 1.8 after (Atop, @) subtracting 32. I suspect there’s a better way to write this, but it’s the first thing that came to my mind…
Sort (/:) the distinct items (nub) of the list. Don’t concern yourself too much with the passive (~) for now, it’s just there so the arguments to take end up in the right spot.
That’s it for today, in my next post on J I want to focus on the language’s excellent plotting capabilities.
The web is full of wonderful information. In fact there’s so much of it, it almost feels intimidating at times. I therefore plan to start a series of blog posts about articles/screencasts/lectures/etc. I enjoyed during the week (they may have been published at a totally different time though).
Beyond City Limits Is the age of nations over and are we entering the age of cities?
Clojure 1.2 and Beyond A presentation by @fogus about the newly released Clojure 1.2. Covers everything that’s important and has some wild speculation about the future too.
2. The possibility to return from within the closure:
123456789101112
>>p=Proc.new{return}=>#<Proc:0x000001008c83a8@(irb):7>>>l=lambda{return}=>#<Proc:0x000001008c4050@(irb):8 (lambda)>>>p.callLocalJumpError:unexpectedreturnfrom(irb):7:in`block in irb_binding' from (irb):9:in `call' from (irb):9 from /Users/michi/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'>>l.call=>nil
I’ve known about this for a while, but as a Rubyists who until quite recently happily ignored Rails, I didn’t know that ActiveSupport changes the “LocalJumpError” from the second example into
123
1 2 3
<span class='line'><span class="sb">`call': Cannot yield from a Proc type filter.</span>
</span><span class='line'><span class="sb"> The Proc must take two arguments and execute</span>
</span><span class='line'><span class="sb"> #call on the second argument. (ArgumentError)</span>
</span>
when you try to return from callbacks like “before_save”. I spent quite some time debugging this before I finally found the solution in this blog post. Instead of
“By relieving the brain of all unnecesary work, a good notation sets it free to concentrate on more advanced problems, and in effect increases the mental power of the race.” – A. N. Whitehead
Yesterday Andreas posted this awesome video of a Game of Life coding session in APL, which really blew my mind. Watch it, it’s well worth 8 minutes of your time!
Being extremely impressed by what I saw, I realized that I never wrote anything in a language from the APL family, so I decided to change that. I couldn’t find a free version of APL running on OSX that wasn’t time limited or required me to apply for an educational license, so I finally settled on J (Wikipedia article), skimmed the docs and wrote solutions to 4 different Project Euler problems. They are all extremely terse, but I lack the APL/J knowledge to further comment on their quality. If you have experience in either language, I’d really appreciate some comments!
Problem 7: Find the 10001st prime.
This ones fairly easy, since the vocabulary contains p: which will return the n-th prime (0 indexed):
1
p: 10000
Problem 3: What is the largest prime factor of the number 600851475143?
1
{: q: 600851475143
Get the tail ({:) of the list of prime factors (q:)
Problem 5: What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
1
*./ }. i.20
Behead (}.) the list of all non-negative integers up to 20 (i.20) and apply (/) the least common multiple (*.).
Problem 1: Find the sum of all the multiples of 3 or 5 below 1000.
This one took me a bit, so we’ll do it step by step. First, apply (/) the residue (|) to the non-negative integers up to (non-inclusive) 1000 (i.1000):
Finally append the two lists (,), remove duplicates (~.) and apply (/) +:
1
+/ ~. ,0 ([: I. =) (3 5|/i.1000)
Overall playing with my first non-von Neumann programming language was a rather fun experience, especially after getting over the somewhat strange syntax and the fact that most “words” have monadic and dyadic versions. From my cursory glances J’s documentation looks pretty solid and the language starts making sense a lot quicker than one might expect. It’s definitely stimulating to play around with and I think I’ll do a bit more of that over the next few weeks, especially since I haven’t yet explored the plotting and OpenGL frameworks.
Ever since I started this blog in January 2005 it was powered by Serendipity (aka S9Y). Lately however I became more and more dissatisfied with it for various reasons, so I finally took the plunge and moved it over to Wordpress. The whole process was surprisingly painless, but did have some caveats, so I decided to post a short description of what I did:
There is a script for migrating S9Y to Wordpress that has been floating around for a while and has been patched/modified by various people. Luckily I found version 1.4, which got updated very recently (June 2010). For some reason it didn’t work for me when I tried to migrate between S9Y 1.5.3 and Wordpress 3.0.1 directly, so I installed Wordpress 2.9.2 first, migrated the content and then upgraded to the most recent version. The import itself was very smooth and successful, categories (which I stopped using a long time ago), users, posts and comments all made it to the new blog! Once you are done importing, you can run several SQL statements provided in readme.txt, so that your new posts will have the same IDs as the old ones, which is necessary for redirecting. For that purpose I added some Apache mod_rewrite rules, so that old post URLs will redirect to the new locations (and so will the RSS and Atom feed so subscriptions don’t get interrupted):
There’s still quite a bit to do though: first I need to find a theme I like (I might even stick with the one I’m using now and just tweak it a bit), then lots of posts need fixes to their formatting because they were written in Textile (I fixed the most recent 2 so far, it’s rather quick and painless). There are also some widgets and static pages I want to move over from the old blog, so I guess this site will be a work in progress for a while. I am however very satisfied with Wordpress and glad I finally did this move I put off for so long.
Since this post got quite popular I decided to incorporate some of the excellent suggestions posted in the comments, so this list now has more than 50 books in it. BTW: I’m not very strict on the definition of “ebook”, some of them are really just HTML versions of books. [UPDATED: 2012-01-18]
Learning a new programming language always is fun and there are many great books legally available for free online. Here’s a selection of 30 of them:
This is far from comprehensive and languages that are completely missing are mostly left out on purpose (e.g. PHP, C++, Java). I’m sure somebody else made a list for them somewhere.
Today I stumbled upon a post called GitHub Stats on Programming Languages, where the author uses R to create various graphs about GitHub’s top 10 programming languages. He was nice and posted his data set, so I had a go at it with Incanter.
Load the necessary libraries:
Then read in the data set (the delimiter defaults to \, which can be changed with the :delim option) and create a (somewhat arbitrary) list of languages to examine:
Get a tabular view of the data:
Narrow the data set down to languages of interest:
Display a bar chart of repositories per user (this has to be within the with-data form shown above):
More graphs:
The full code:
I just love how simple Incanter makes this type of thing. It’s an immensely cool and useful library, which can do much more than what I showed in this post (and previous ones). I hope that one day there’ll be a book about it!
After years of being an avid Vim user, I recently succumbed to the temptation of Emacs and haven’t looked back since. Now that I slowly understand the concept of “living in Emacs”, I also wanted a fullscreen mode. Turns out you’ll have to patch and build Emacs yourself for that if you are on OSX, so here’s a step by step guide on what I did to build the current Git HEAD (“About Emacs” reports the version as 24.0.50 by the way) with fullscreen support, based on Steve Purcell’s post from last January:
To toggle fullscreen mode call “M-x ns-toggle-fullscreen”, which I have bound to “M-RET”. Looking forward to try this on 1920×1080 at work on Monday!