Tag ruby (6)

na nanana nana na na...
Mood: pensive
Posted on 2006-05-31 09:35:00
Tags: movies pictures ruby palmtogooglecalendar
Words: 451

...Katamari Damacy! djedi bought WeKatamari yesterday before he left (thanks!) so I played last night. Goood stuff. I love doing the flower level (collecting as many flowers as you can) - very relaxing. Quitting without saving and losing my data was somewhat less relaxing, but if you think I'm not going to redo those levels tonight, you'd be sadly mistaken.

I have the top Google result for "pic6"! Unfortunately it goes to this picture, but you can't win them all.

Speaking of pictures, I put pictures from Jessica's graduation up last night.

Speaking of things I did last night, the palm to google calendar thing is basically done. I have a few tweaks to do, but I'm going to link to it soon. fairydust1, want to test it?

So last time I talked about getting the ruby script to return that it was done while forking a new process. I was almost correct, but instead of doing this in the new thread:


# Create session and return session id to browser
pid = fork do
$stdout.close
$stdin.close
$stderr.close
# Do long-running stuff
end
Process.detach(pid)

you instead just need to do this:

# Create session and return session id to browser
pid = fork do
$stdout.close
# Do long-running stuff
end
Process.detach(pid)

Closing $stdin and $stderr just leads to problems (which was why passing parameters weren't working before).


Speaking of...umm...lj-cuts, I saw X-Men 3 this past weekend.
I liked it, all in all. The parallel between mutants and gays was extremely striking in some parts. I also liked the shift of power that the vaccine gave the humans - now they had a weapon against the mutants so it wasn't just a case of "watch the mutants kill the humans, who have no hope of ever retaliating". I like Storm the character (especially with the white hair!), but I didn't think Halle Berry did a good job acting this time around, especially during the scene where they're debating whether to keep the school open. It felt very fake to me.

Also, I loooove Ian McKellen. Maybe it's the white hair talking, but I like the obvious mutual respect he and Professor X have for each other. When Magneto lost his power, even though he was clearly a bad guy, I felt very bad for him since his identity was so wrapped up in his power.
If you go and see it, be sure to stay until after the credits end! There's a final scene that's actually very significant.

I'm looking forward to a number of summer movies - at some point I'll post the ones I want to see and y'all can make fun of me. Oh, there was a trailer for Snakes on a Plane, and it was good.

22 comments

warning: good weekend ahead
Mood: happy! not sick!
Music: Lordi - "Hard Rock Hallelujah"
Posted on 2006-05-26 09:37:00
Tags: pictures music ruby palmtogooglecalendar links
Words: 500

Already this weekend (starts on Thursday!) has been good - we finished Maraudon last night in WoW, which was fun (despite an infuriating part where Dextra and I (the two people who can rez) died and had to spirit rez and fight our way back. Scary!), and I got a shiny new dagger and orb.

Another good thing - I'm not sure yet, but I think I've solved my work problem...but not in a great way. It's like finally arriving at Disney World in Georgia (the country, not the state), and you're tired but happy you finally got there, and then getting out and realizing that Tennessee (where you started) is really right across the street from Georgia (the country, not the state). And you think everyone is mocking you for taking such a roundabout journey when you were right there, except they presumably aren't. Whee. I think I'll put this analogy to rest :-)

I have a problem...I cannot stop listening to "Hard Rock Hallelujah"! Seriously. Sometimes songs stick in my head so long, it actually makes my stomach hurt (and can keep me up at night). This song isn't there yet, but it's headed that way...

I put up pictures of Stephen's graduation. Next up - pictures from wonderjess's graduation! And then the pictures I will have acquired in the intervening time. Yikes.

Had a breakthrough in the palm to google calendar thing last night.

So the problem I had been having was that, when you connected to start the syncing process, it wouldn't return until it was done, which means that you couldn't poll for status updates. (actually, I guess you could, but then you'd have two connections open at once unnecessarily) So, I tried something like this:


# Create session and return session id to browser
pid = fork do
# Do long-running stuff
end
Process.detach(pid)

Interestingly, this works when you run the script from the command line, but not when you're doing a POST to it! I'm not sure if this is an Apacheism or something. After digging around for a while, I found the solution is to do something like this instead:

# Create session and return session id to browser
pid = fork do
$stdout.close
$stdin.close
$stderr.close
# Do long-running stuff
end
Process.detach(pid)

(Note: this is incorrect. See update here) and this makes everything work well. Except that I'm having some difficulty access variables declared in the pre-fork section inside the forked process. I bet they're getting destroyed or something when the parent finishes. But, on the whole, I'm closer to getting it to work. Yay!


"How to cheat good" (by a college professor). Tip number 8 is hilarious!

Top 50 Places to Have a Beer in America - I was a little disappointed/surprised there were no Texas places in there. (although this is just the places with highest scores on BeerFly - maybe there's some geographic bias there?)

DeLay campaign cites Colbert bit as evidence of innocence...um, wow. After the White House Correspondents Dinner thing, I thought everyone had figured it out!

7 comments

brain dump
Mood: hopeful
Posted on 2006-05-15 09:56:00
Tags: ruby palmtogooglecalendar politics
Words: 957

Man, I have a lot of things on my mind!

So Prop 6 passed here in Austin (allowing the city to give health benefits to same-sex couples). I gotta say, it feels really good to finally win on a gay issue here in Texas. Yay!

djedi and I went to his brother's graduation in College Station Saturday morning. It was nice, although the ceremony itself was fairly boring (naturally) and it was fairly chilly inside. We went out to lunch afterwards and we got to meet his girlfriend, who was nice. I also took a toooon of pictures that I need to sort through at some point. A&M wasn't too scary - they say "Howdy" a lot (I could get used to that!), and there was some whooping, but it's all good. wonderjess graduates next weekend, so I'll be flying up to sunny (and hopefully not too cold!) Rochester on Friday.


So, going into the weekend the backend was written mostly (I could update my google calendar by running a ruby script from the command line), so I needed to put a web interface on top of it. This was tricky for a number of reasons.

First of all, the way I have to do authentication with Google right now, I have to ask for the user's Google username and password. They're working on a different way to do this, but for now this is what's required, so I wanted to make sure the page was using HTTPS to collect that information. I set up a certificate (that I signed myself - not worth paying $50 or whatever it costs to have someone else sign it) and after a few hiccups, got things working.

Then I started thinking about how this was actually going to work. The problem is that deleting and adding the entries will take at least 30 seconds, and sometimes much more, so I wanted an asynchronous way to do it. I had read some stuff about Comet, which is a bleeding edge application model. Basically, the idea is that the client opens a long lived connection to the server, and because of this the server can push back data whenever it wants (which isn't possible under normal HTTP). This sounded perfect, because I could connect to the server when the user pressed "Upload", and the server could send back progress updates while it was working, and have the client close the connection when it was done.

So, great. There are some problems. One is that web servers that aren't aware of a Comet-like approach don't scale this approach very well - having lots of connections open for a long time. That's OK for me, I'm not worried about too many people using this thing all at once :-) The other problem is that apparently it's hard to get working correctly. It was hard to find easy to understand examples that actually use this approach, and the one that I did find and understand relied on having the server basically return a text stream that gets progressively updated. I could not for the life of me make this happen correctly - it would wait until the whole thing was done, then display the whole stream, which obviously wouldn't work. I looked around for some other way to do this, and found a Mozilla/Firefox-only solution which was no good. So finally I threw up my hands and gave up on Comet for now. Maybe I'll take another look at it in the future.

So, I decided that the request to upload would finish quickly and return a session ID, and the client could call a script to get the status of that session every few seconds, which would simulate the same effect. This required some way to share session data across ruby processes, and CGI::Session turned out to be perfect for me - it by default stores session data in a file, so I can just read that file when I receive a request to get status.

Another problem was uploading the Datebook file itself - it's easy to do this using a normal HTML form, but because of security restrictions, Javascript can't read files off of the local drive (which makes sense...). So I couldn't use my normal trick of having the "submit" button have an onClick handler that sends the request, because that handler couldn't get the file data. Instead, I found out more information about the hidden IFRAME technique (which was used to do XMLHttpRequest-like things before XMLHttpRequest existed), so I'm having the form do a POST with its target set to the hidden IFRAME. This works well and I can receive the file on the other end - now I need a way of getting the session ID returned to the IFRAME to the parent document (the link I found this morning and looks like it will work well).

I was also baffled for a while that I was receiving the file correctly, and processing it with pilot-datebook, but the resulting file in longtxt format wasn't showing up. After butting heads with the problem for a while, I realized that I was using Tempfile to generate a temporary filename, but it was deleting the file as well, so that was an easy fix.

So most of the hard problems have been solved - I still need to do the processing and integrate that with status reports (and abstract that part out so I can still use the command-line version), and I need to handle errors better (at all :-) ), but I'm very happy with where things are right now.
...in short, things are going well.

Apparently having the NSA intercept domestic phone calls was Dick Cheney's idea, and NSA lawyers were against it.

51% of people disapprove of the domestic spying.

4 comments

weekendish activities!
Mood: blah
Posted on 2006-05-08 09:59:00
Tags: dallas ruby palmtogooglecalendar
Words: 475

So djedi and I went up to Dallas this weekend to visit his sister and two nephews. I had a good time, despite the long drive and somewhat awkwardness (since I don't know them too terribly well). The kids are really cute, though, and they were pretty well behaved. I played with the older one (Donovan) a fair bit and he called me "Uncle Greg" once near the end, which really made me feel good. Man, I don't know how they keep up with them - they're ages 5 and 3 and bursting with energy!

I did take some pictures, but didn't have time to put them up last night. Maybe tonight...

Saturday night we went out to see "Ice Age: The Meltdown" which I wasn't terribly impressed with. It was clearly aimed at kids, but unlike "Shrek" and, oh, every Pixar movie made so far, there wasn't much there for adults. I chuckled a few times, but that was about it. The kids really seemed to enjoy it, too - they're old enough to mostly sit through a movie at the theatre, which is neat.

I hate Dallas. This is not news to many of you, but there it is. While driving up there, I discovered another reason I hate it. So the interstate system has some pretty neat features, one of which is that interstates ending in 5 are roughly parallel across the country (i.e. I-5 goes through California, I-35 and I-45 go through Texas, and I-95 goes along the East Coast, etc.), and interstates ending in 0 are the same thing, but east-west (i.e. I-10 goes through Texas, I-90 goes through, erm, North Dakota or something). However, Dallas totally screws this up - not only do I-35 and I-45 meet in Dallas, so do I-20 and I-30! It's making a mockery of this beautifully designed system. Screw you, Dallas! (the floor is open for more reasons to hate Dallas)

Ooo, might Futurama be coming back?

So I stayed up late last night and made some more improvements to my Palm to Google Calendar importer. I fixed some irritating timezone issues (thanks to the TZInfo module) and, instead of deleting all existing events and adding all new events, now it compares the new ones with existing ones and only deletes and adds ones it needs to. Sort of like a diff/patch type thing. I also went ahead and split up repeating events into individual events so the calendar could handle it - hopefully they'll fix that someday and I can go back. Anyway, once I improve the Palm parsing of events, it'll be pretty much feature-complete and I'll put a web interface on it so anyone can use it. (at least maybe fairydust1 will find it useful) But even if nobody else does, it's very useful for me, and I'm learning more about Ruby and such. Whee!

14 comments

ruby scoping
Mood: confused
Posted on 2006-04-18 09:41:00
Tags: ruby weight programming
Words: 218

I weighed in this morning, and I'm at my lowest weight since starting to track it (oddly enough, despite eating many tasty cookies and candy on Sunday). Hooray!

On a completely separate note, I'm learning Ruby to use in my next project. It seems like a nice language, but I have a complaint already. Consider the following code:

[1,2,3].each {|e| print e, " " }

This prints out "1 2 3 " - the each operator iterates over the elements of the array, and the block that follows it ({|e| print e, " " }) operates on each one of them. So that's fine, and e is undefined after the block executes, as I would expect.

What I don't like is that the following code:
e = 10
[1,2,3].each {|e| print e, " " }
print e

prints out "1 2 3 3" - the e argument to the block ends up overwriting the e variable declared outside the block! This seems like a big violation of scoping - shouldn't the e inside the block be unrelated to the e outside the block? Can anyone (omega697, perhaps) explain this to me?

I mean, I can see why it might be useful (if you want to save the last value that the block executed on), but the penalty of possibly overwriting a variable outside the block's scope seems a bit much to handle...

10 comments

Happy Easter!
Mood: tired
Posted on 2006-04-17 00:14:00
Tags: pictures ruby
Words: 73

Happy Easter, all! I took some pictures of an Easter get-together at destroyerj's place.

Also, I'm learning Ruby to work on a LiveJournal archiving project of mine, and Why's (Poignant) Guide to Ruby is easily the weirdest, most bizarre programming tutorial I've ever seen, or expect to see. Even if you don't want to learn Ruby, I'd recommend skimming through it (and the pictures), and then wondering how Ruby relates to cartoon foxes.

3 comments

This backup was done by LJBackup.