fREWdiculous!
15 Feb
First off, if you did not already know, rakudo is the first implementation of perl6. There is no plan for an official Perl 6 implementation, so we have to give this implementation a name other than perl6.
Anyway, I know that you are all working diligently on perl6 like I am, so I know that you are having trouble because you have to rebuild parrot and rakudo which is kindav a hassle. Let’s remedy that now! (Much of this information was taken from this post by Moritz.)
First you’ll want to get your initial checkouts. I’ll presume that you have git, subversion, and everything else required to build rakudo already installed on your unix based computer
Also, I will assume you check them out into ~/dev. I actually have a ~/personal and a ~/scripts that I check this stuff out into for my laptop and desktop respectively, but the point is, they both get checked out to the same directory.
So to checkout both you’ll do this:
1 2 3 | cd ~/dev git clone git://github.com/rakudo/rakudo.git svn co https://svn.parrot.org/parrot/trunk parrot |
So now you should have a ~/dev/rakudo and a ~/dev/parrot. Now make a script called build_rakudo.sh inside of ~/dev and fill it with these lovingly crafted characters:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/bin/bash cd ~/dev/parrot # clear out any old cruft that used to be there. # this isn't always necessary, but sometimes it # is and we want this to be entirely automated make realclean # updated the source svn up # configure it for your local system perl Configure.pl # and build it! make cd ~/dev/rakudo # remove the old symlink so make realclean # doesn't delete our checkout/build rm parrot # see above make realclean git pull # make a symlink of the above parrot # directory in the rakudo sourcetree ln -s ../parrot parrot # see above perl Configure.pl make # I just do this so that I can run perl6 # and have an "interactive" perl6 it isn't # really interactive, but it's better than # write, execute loops make perl6 |
And then I’d recommend doing a crontab -e and adding
1 | 0 17 * * * sh /home/foo/dev/build_rakudo.sh |
so that it gets built every day, starting at 5 pm, so it’s ripe for work when you get home
And one last thing: working on perl6 locally can be kindav a drag because it doesn’t tell you the result of all of your lines when you are using the fake-o interactive mode. A nice thing to do is this:
1 | sub p($anything) { $anything.perl.say } |
That way if you give it an array, it will print out the array as an array instead of some weird tab delimited stringification or whatever.
Happy hacking!
13 Feb
Today I was talking with a friend about the stuff we are doing at work and I mentioned to him how I was planning on doing the authorization. Since I had only thought about it at that point I didn’t even know if my idea was valid Perl syntax, let alone a feasible idea. But enough with the backstory, how about some real information.
Let’s assume that we have a webpage that lets you read user data and write user data. Theoretically we have already logged the user in, so we know who they are talking to, and we have a simple database model of the roles the user is authorized for. That’s no fun but it’s pretty easy. Three tables: one for the user, one join table from user to roles, and one that lists roles. So if we wanted to limit a sub to a user with role ‘read_user’ and ‘write_user’ we could do this:
1 2 3 4 5 6 7 8 | sub read_user { my $self = shift; if ($self->user->has_role('read_user') and $self->user->has_role('read_user')) { # display user data somehow } else { # display some form of error } } |
That’s really a fine way to do it. It works. It’s how most things work. But it would be no fun to have to write that for essentially every page on a site. That’s a drag!
Perl has this thing call attributes; which is basically a way to tag functions. At first I thought, “Hey, we’ll just tag a function with it’s roles and have validation work based on that. So our previous thing would look like this:
1 2 3 4 |
That would be great! But how on earth would you do something like that? I started off looking at the source to AutoRunmode which basically gave me this idea in the first place. There is some very deep magic in there, so I decided to keep looking. The source to AutoRunmode references Attribute::Handlers, originally by Damian Conway (author of numerous Perl
books
) which allows me to at least do something when someone includes a handler. That’s a start. So I looked at how to use Attribute::Handlers and after seeing what was possible I decided it would be easier and more clear to change my goal to this:
1 2 3 4 | sub read_user : Authorize(qw/role_read_user role_write_user/) { my $self = shift; # display user data somehow } |
That way if I use the Attribute::Handlers system I write a single function that gets a list of roles (amongst other things.) Then came the hard part. How can you change a function in Perl? Well, it turns out that changing a method is Kinda Hard, but Dave Rolsky Stevan Little made Moose, which makes it totally easy!
So this is the final mockup of how I plan on doing it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | package MyClass; use feature ':5.10'; use Attribute::Handlers; use Moose; sub Authorize : ATTR(CODE) { my ($class, $globref, $referent, $attr, $data, $phase, $filename, $linenum) = @_; # deep magic that gets the name of the function my ($function) = ${$globref} =~ /::([^:]+)$/; $class->meta->add_before_method_modifier ($function => sub { foreach (@{$data}) { $class->validate($_); } }); return; } sub read_user : Authorize(qw/user_read user_write/) { my $self = shift; say "reading personal files!"; } sub validate { my $self = shift; my $role = shift; say "validating $role for ".$self->user; } sub user { my $self = shift; return 'frew'; } |
Debolaz from #perl helped out a lot with this one. The only major thing left is some way to check all functions with the attribute ‘Runmode’ and ensure that they also have the Authorize attribute with at least one thing in there. That way we can’t accidentally forget to authorize people. I don’t think that will be very hard, but even if we can’t do it, this is still great.
The only thing I am worried about is whether I can use Moose in a CGI::App class. Probably, but we’ll see.
Hurray for Perl!
10 Feb
Metropolis Part 2, by Dream Theater, is this weeks AOTW. This is one of those rare albums that must be listened to entirely, in order, and gaplessly. I am sure lots of you music people do this anyway. I know that I do for sure. But the thing is that these songs mostly have seamless transitions along with an important, plotish order.
Metropolis Part 2 is a concept album. It is Prog Rock as it’s by Dream Theater. The concept has something to do with murder and reincarnation; at least that is what I have gathered after listening to it numerous times. It is one of the few albums, in my opinion, that pulls off sound effects well. Lots of songs use sound effects as part of the song. How many do you know that use sound effects as sound effects and still sound good and actually have something to do with the song?
I think this is a great album to sit down and just listen to as opposed to listening to at work. I also listen to it at work and while I drive etc. But the lyrics and the music itself are worth paying attention to.
I like every single song on the album, which I think is unusual, but I will still note my favorites.
My favorite tracks of the album: Finally Free, Fatal Tragedy, Beyond This Life, The Dance Of Eternity.
Colors: Red, Black, Blue.
9 Feb
I watched this keynote from frozen perl this weekend and it was pretty great. There are plenty things to take from this presentation, but the thing I want to mention comes from slides 66-77. Consider that mandatory reading to understand this blog post.
Now read this, this, and almost any of these.
Caveat Lector: All of those links may be outliers. I am certainly not reading a statistically valid sample of The Webternet; so maybe just consider this some random observations from this random dude.
Also: All of the above linked people are smarter and more motivated than I am. I would not criticize their intelligence in the least and their technical skills has my respect for sure. What have I done? A job? Helped move some books to people that needed them at school? Some stuff at a hospital? Compared to Rails, Mongrel, and Archeo- whatever. Compared to those guys I am nothing. Keep that in mind.
I just think it is important that in the perl world we have keynotes where people say: “Be Excellent to Each Other.” People say that perl is dead. I disagree. You should see how many blog posts there are out there saying, “no, perl is not dead!” But I would much rather perl be dead than perl be a bunch of jerks.
Basically this boils down to the difference between me and those other programmers. I think that our priorities should be:
Even if you aren’t a Christian I still think that exactly that priority list matters: Code is useless without users. Maybe they think they are exceptions because they are the users. Fine. I just know that if I see Giles, Zed, or DHH in real life I will be like, “Wow, what a great coder! Probably don’t want to actually hang out with them for more than 10 minutes though…”
Maybe I’m wrong though. Maybe the internet is just not a place for being nice. I just know that I am going to try to do my best to “Be Excellent to Each Other.”
5 Feb
How do you manage numerous windows when you have a gigantic viewing space? Or what if you have a really tiny viewing space? At work I have two 22″ monitors and maximization is just too ridiculous to consider and it is typically a huge waste of space.
I decided that if I am going to have a lot of windows open I should look into something that can help me tile things correctly. A lot of the tiling solutions out there are all or nothing. Once you use them you can no longer have overlapping windows, you must use their strange layouts, and if you don’t know their hotkeys you can’t use your computer. I decided that for now, none of those are an option.
Instead I found a program called GridMove. It allows you to have numerous grids to snap windows into. You can achieve “snapping” with mouse interaction or with various hotkeys. Overall I have been extremely happy with it.
I even wrote a tiny AHK script to open programs for one of my projects and place them in the right place.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #o:: Run "C:Documents and SettingsfrewMy DocumentsCodeaircraft_ducting" WinWait, "C:Documents and SettingsfrewMy DocumentsCodeaircraft_ducting",,3 sendinput,#6 Run "C:Program FilesApache Software FoundationApache2.2logserror.log" WinWait, BareTail,,3 sendinput,#5 Run "C:Program FilesVimvim72gvim.exe" -c "call ACDRI()" -S C:Documents and SettingsfrewMy DocumentsCodeaircraft_ductingsession WinWait, GVIM,,3 sendinput,#4 Run "C:Program FilesMozilla Firefoxfirefox.exe" -new-window http://localhost:8080/devcgi/init.plx WinWait, "Mozilla Firefox",,3 sendinput,#1 return |
But that’s not all! I tend to use splits in my text editor a lot, and with that in mind you may notice the about call to ACDRI() and the S switch. S reloads all of my previous editor settings, including splits, and ACDRI() opens my project file.
1 2 3 4 5 6 7 8 9 10 11 12 13 | function! ACDRIEnd() wincmd h wincmd h wincmd h q! mksession! "C:Documents and SettingsfrewMy DocumentsCodeaircraft_ducting"session qa endfunction function! ACDRI() Project "C:Documents and SettingsfrewMy DocumentsCodeaircraft_ductingproject" set foldlevel=1 endfunction |
And lastly, at home where monitor space is much more of an issue, I tend to have gvim and a console side by side, with numerous splits each. The console splits are achieved with ^a S and ^a |. You can move to the next one with ^a
Anyway, does anyone have any other tips having to do with automated window management?
3 Feb
1 | gvim `grep 'strip_tags' * -Rl | xargs` |
This will open all of the files that have the string ‘strip_tags’ in them in a single gvim window. (Can I call this one-liner: too lazy to even copy paste?)
3 Feb
So today the Ext JS guys posted about their conference in April. We use Ext JS at work and I have become pretty competent in using the framework for UI design. A lot of the things that they are adding in Ext JS 3.0 will make the toolkit more compelling. The most significant of all will be the accessibility changes and the addition of Ext Core as a standalone library.
Anyway, with that in mind I asked my boss if I could go and it was decided that I am going! I am very excited! This is the first conference I have gone to and I think it will be a good one. The talks that I am looking forward to the most are the Keynote with Douglas Crockford, Ext 3.x – What’s new & how to use it, Introducing Ext Core, Building Accessible Apps for Ext JS and Ext GWT, Refactoring, Application Deployment, Building Usable Interfaces, Optimizing Performance, and Critical Developer Tools.
That may seem like a lot to be excited about to you, but I am quite stoked. By my reckoning that’s %33 Ext talks and %66 general javascript (or more general) programming talks, which is quite acceptable to me.
I also think it’s pretty Cool that they give you a discount based on how long you have had a login for the forum and how many posts you have made to the forum. I got a 25% discount based 200 posts and five months of participation. That really is an interesting way to foster community.
When I do end up going to the conference I will do my best to distill the talks into written word
2 Feb
Ultravisitor, by SquarePusher
, was one of the first experimental techno bands that I was introduced to. It has the distinction of being the only music I’ve ever listened to with my friend Fjord that he asked me to change. It is quite noisy, but it also has some very pretty parts.
Do you have friends who say, “Yeah, I’ll listen to pretty much anything except Country music,” or some variation of that? Well, show them this album. They might be down at first, but they’ll probably change their mind after a few tracks. I even had a friend who claimed that this album doesn’t count because “It’s not music!” That is certainly a falsehood, as I think this album is quite an interesting experience. You may not be able to listen to it all the time, but it’s still worth hearing at least twice.
An interesting fact to note about this album is that, while it is techno, SquarePusher plays at least one “real” instrument, the bass guitar, and it sounds very pretty. The bass is very environmental, which is probably true of most bass guitar, but this is much more in the foreground.
Favorites: Iambic 9, Ultravisitor, Circlewave.
Colors: Black and White and Pink and Cyan
2 Feb
This Saturday someone broke into my car. They stole my GPS unit, my awesome Treo 650
+ 32 Gig SD Card
mp3 player, and the faceplate to my stereo. I am not telling you this so that you’ll feel bad for me; I am telling you so that you will understand why I have chosen Good News For People Who Love Bad News
by Modest Mouse as the album of the week.
Out of all of the bands that I know and love, Modest Mouse is probably the second most depressing. Their worldview is almost entirely pessimistic. The music is great in that it’s easy to listen to and great to jam out to, but it is also unusual in the strange singing style. Modest Mouse is good to listen to when you are depressed (assuming you don’t have suicidal tendencies) and also when you just wanna rock out with the windows down.
One other interesting observation: I think that Float On is probably most (if not only) positive song by Modest Mouse. An interesting thing about that is that it presumes negativity but says that sometimes things are good and that ultimately everything will be “OK.”
Favorite Tracks: Float On, The Ocean Breathes Salty, The View, One Chance, and The Good Times Are Killing Me.
Colors: Light Blue and Brown.
2 Feb
A good friend told me that instead of making huge lists of albums I should instead make a post a week for an album. What a great idea! I begin this today.
Caveat Lector: I don’t care if a band is popular, is musically weak, socially unacceptable, or any other reasons unrelated to the sound of a specific album. I don’t care about what you said about it or what your indie reviews said. I just care about if I liked the album. With that said, let’s get started
I figure that if I have to start with something I will start with (statistically) my favorite album. This surprises me, but according to last.fm October Rust by Type O Negative is my favorite album of the past 12 months. It seems that way from that graph anyway.
My roommate tells me that Type O Negative is technically classified as industrial. I have looked all over the place for something that’s actually similar and I can’t seem to find anything. October Rust is excellent for background music, but it’s also excellent if you want to have your very own personal hour and twenty six minute long Halloween.
I don’t know if using words to describe music makes much sense, so that’s all I’ll do for that this week.
My favorite tracks of the album: Love You To Death, Red Water, Die With Me, Wolf Moon, and Haunted.
Colors: Black and green.