Well, I don't follow @cpan_new, but I do follow @garu_rj and sometimes that's just as good! He just alerted us to the new Perl module, Devel::hdb. It looks promising! I just ran
perl -d:hdb sticky.pl
and away we go!
Well, I don't follow @cpan_new, but I do follow @garu_rj and sometimes that's just as good! He just alerted us to the new Perl module, Devel::hdb. It looks promising! I just ran
perl -d:hdb sticky.pl
and away we go!
Ruby is 20 years old today! To celebrate, they just released Ruby 2.0!
Here is a shelr of me installing it on my laptop for use with rbenv. At the beginning, I'm checking for the ruby-build, which wasn't there yet, so I did it the long way like the rc1 build here. If it had shown up in ruby-build, it would have been much shorter like the rc2 build further down the same page. [Update: It's there now, so go ahead and do it the short way!]
I love programming in Perl, Python, and Ruby (at the end of that shelr, you can see me type "rbenv list" which is a perlbrew command and a pythonbrew command, but not an rbenv command). All three of these languages have grown quite a bit in recent years. Each has handled the version number changes that go along with these language changes differently. None well. As someone who is mostly interested in the latest versions of these languages, I seem to spend an inordinate amount of time talking about older versions. In the case of Ruby, it's a huge relief to finally have version 2.0; I think it will simplify a lot of conversations.
Addendum (2013-03-06): Matz speaking on Ruby 2.0.
Nicolas Mendoza just created this cool logo for something called Pumpkin Perl. Looks neat! Here in Maryland, we'd have to adjust it a little, I think...
The other day I noticed some videos quit working in Google Chrome on both my Ubuntu 12.04 and 12.10 machines. HTML5 videos still worked, but Flash videos did not. I don't know if Flash is the most fragile software ever, but it certainly fails often enough that I didn't really blink. In fact, I decided to wait to see if it would fix itself. The good news is, there was a Google Chrome update this morning! The bad news is, it didn't fix the Flash video problem.
So I opened up chrome://plugins and turned off the newest flash plugin (Shockwave Flash 11.5r31), presumably letting the previous one (11.2r202) take over.
This seems to have restored Flash video capability to Google Chrome. At least, for the time being.
Hey, the first Ruby 2.0 release candidate has been released! These days, I've been using rbenv to manage my Ruby installations, but I don't see rc1 in ruby-build yet. No matter, it's easy to add it to rbenv without ruby-build. First, fetch the source code and untar it.
$ wget http://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-rc1.tar.bz2 $ md5sum ruby-2.0.0-rc1.tar.bz2 24cebdda11e01ff4889ac983cd7dc02c ruby-2.0.0-rc1.tar.bz2 $ tar xf ruby-2.0.0-rc1.tar.bz2 $ cd ruby-2.0.0-rc1Since rbenv uses the directory name to determine the versions, we just adjust our prefix in the configure step of the usual configure-make dance.
$ ./configure --prefix=$HOME/.rbenv/versions/2.0.0-rc1 $ make $ make test $ make installNow a rehash will pick it up.
$ rbenv rehash $ rbenv global 2.0.0-rc1 $ ruby -v ruby 2.0.0dev (2013-01-07 trunk 38733) [x86_64-linux]
Oops! This ruby doesn't seem to know it's the release candidate, but it is.
Note that they plan on one more release candidate and then Ruby 2.0 will be released!
Keyword arguments! Lazy Enumerators! Onigmo! Exciting times!We will release 2.0.0-rc2 in early February, and 2.0.0-p0 at 24th Feb. (the 20th anniversary of Ruby).
$ cd .rbenv/plugins/ruby-build/ $ git pull $ rbenv install 2.0.0-rc2 ... $ rbenv global 2.0.0-rc2 $ ruby -v ruby 2.0.0dev (2013-02-08 trunk 39161) [x86_64-linux]Gosh, rbenv is great, innit?
I visited my Mom recently and I returned home with her old computer.
It was giving her problems (aperiodic crashing), so she got a new one. This platform was abandoned by its manufacturer long ago, so there was no hope of updating it anyway. This machine has a PowerPC chip in it, which is completely different from all the other machines I use, so I decided to see if I could put Linux on it.
Its specs are pretty modest (it's over ten years old), so I wanted something lightweight. I also wanted something up-to-date, so I was pleased when I discovered that Lubuntu 12.10 supports PowerPC. This is a version of Ubuntu based on LXDE, a much lighter weight desktop. Perfect!
Unfortunately, I was unable to get it to install. This machine has nVidia graphics and the nouveau driver used by Lubuntu 12.10 didn't seem to like this particular graphics card. By default, I just got a blank white screen. I tried a number of things, but none of them worked. I even tried
boot: Linux nouveau.modeset=0
which I really thought should do it (isn't modeset zero basically off?), but that gave me crazy colors!
That's the LXDE login screen. The rainbow should be a pretty blue background, the lighter colored rectangle should be the display manager login dialogue, and the little black square should be the mouse pointer. It's even worse if you actually manage to log in!
I was able to boot into single user mode
boot: Linux nouveau.modeset=0 single
and get a console that I could try out a few things with. But nothing worked. The nouveau driver just did not like this card and no other drivers in 12.10 would handle it.
Next, I tried Ubuntu 12.04. It had the same problem with the nouveau driver, but I was able to compile the old nv driver from natty (I tried compiling the nv driver for 12.10, but I couldn't get it to work). After some amount of fussing, it seems to be working fine. I tried both LXDE and Xfce, but in the end I just went with plain Openbox and no desktop. I quite like it and might just keep it around for programming with. It's a pretty nice keyboard. I've barely got it configured and it already does most of what I need. That first photo shows an Emacs window with a Perl script in it and an xterm window. That covers about 90% of my computing needs right there!
And, yes, that's a little penguin thumb drive that I got for Christmas!
I thought it was appropriate to use it to install Linux on this formerly non-Linux computer!
So, I've got the current LTS of Ubuntu installed, but it seems this might be the last version that runs on this machine. Unless someone figures out what's up with this nouveau driver!
The jaws that bite, the claws that catch!
Today's Perl Advent calendar talks about file locking, which is always mimsy. To continue the gift wrapping metaphor...that all works fine when you're wrapping gifts in the bedroom, but what happens when you decide to use the laundry room instead? That room has a Dutch door on it. Are you sure you locked everything correctly?
Oops!
In this metaphor, the bedroom is mounted locally, but the laundry room is mounted via NFS. Your locking scheme might work, but it might not. There are different kinds of Dutch doors with various latches and locks.
I've had good luck with File::NFSLock, which uses linking rather than flock. A common use case is creating a cron job that can only run one instance at a time.
I just spotted Nuba Princigalli's tweet on pretty colorful JSON. Neat!
My first thought was that Perl could do the download without curl
perl -MLWP::Simple -MDDP -MJSON -e 'p decode_json get shift' http://www.reddit.com/r/perl.json
My next thought was that Mojolicious could do the whole thing
perl -Mojo -E 'say r j g(shift)->body' http://www.reddit.com/r/perl.json
The g does the HTTP GET, the j decodes the JSON, and the r dumps it out. But it uses Data::Dumper. How to get it to use Data::Printer instead? I guess we could just use Data::Printer directly
perl -Mojo -MDDP=alias,dump,output,stdout -e 'dump j g(shift)->body' http://www.reddit.com/r/perl.json
Both Mojo and DDP are defining a p, so I'm asking DDP to use dump instead. And DDP uses stderr by default, so I'm asking it to use sdtout instead.
Hrm. Not very satisfying. I feel like I'm fighting both modules. Is there a Data::Printer plugin for Mojolicious that I'm not aware of?
Recently, I talked about asynchronous page loads in Perl three different ways (using AnyEvent, Mojolicious, and HTTP::Async). Commenters fixed the Mojo example and added an IO::Lambda example. Another poster created a Perl 6 example.
Today, I did it in Go, which has concurrency built in to the language. That is, no special modules are needed to load the pages asynchronously; if we wrote a program to load the pages one after another instead, the import lines would be the same.
package main import ( "fmt" "io" "io/ioutil" "net/http" "time" ) func loadpage (url string, c chan<- string) { start := time.Now() response, error := http.Get(url) if error != nil { c <- fmt.Sprintln(error) return } length, _ := io.Copy(ioutil.Discard, response.Body) response.Body.Close() c <- fmt.Sprintf("%-25s has length %8d and loaded in %.2f s\n", url, length, time.Since(start).Seconds()) } func main() { urls := []string{ "https://www.google.com", "http://www.windley.com/", "https://www.bing.com", "http://www.example.com", "http://www.wetpaint.com", "http://www.uh.cu", } start := time.Now() c := make(chan string) for _, url := range urls { go loadpage(url, c) } for i := range urls { fmt.Print(i, " ", <-c) } fmt.Printf("Total elapsed time %.2f s\n", time.Since(start).Seconds()) }
Running this gives
$ go run apl.go 0 Get https://www.bing.com: certificate is valid for a248.e.akamai.net, *.akamaihd.net, *.akamaihd-staging.net, not www.bing.com 1 https://www.google.com has length 12400 and loaded in 1.01 s 2 http://www.windley.com/ has length 50178 and loaded in 1.04 s 3 http://www.wetpaint.com has length 74952 and loaded in 1.06 s 4 http://www.example.com has length 2966 and loaded in 1.09 s 5 http://www.uh.cu has length 57304 and loaded in 2.97 s Total elapsed time 2.97 s
Nice! I'm still new at Go, but so far I really like it.
Recent Comments