Saturday, December 15. 2007I'm in Rails
I've made a code contribution to Ruby on Rails. It was minor, but I'm glad I could help. See ticket 10435 and changeset 8386.
Supposed to get some rain today...keeping my fingers crossed. Update 2007-12-17: Looks like my patch made it into Rails 2.0.2. And we did get that rain, but more would be good. Update 2008-03-17: I managed to get another small patch committed. Go open source! Monday, December 10. 2007Heat Wave"It was summer in December, blowing heat waves in my mind..."I think that line was meant to give you a feel for how unusual the southern hemisphere seasons must feel to those of us up "on top." But whether you've been below the equator or not, it hasn't been hard to get a feel for austral summer in South Carolina lately. It reminds me of being in Sydney in December years ago. Yesterday the temperatures here hit the mid 70s. I've seen that in December before in the years I've lived in SC. But I don't recall a December forecast like the one I saw this morning. Highs of 76°F for the next three days, then 72 and maybe some rain (please!) on Thursday, and then the cold rolls in on Friday, only a high of 67. Having grown up north of here, I guess I have a mindset that it's supposed to be cold for the holidays. And usually it is somewhat cold in upstate SC for December. But it's hot out and we should be kayaking instead of Christmas shopping! Saturday, December 8. 2007Formatting a Javascript Date for MySQL
I don't like to code in JavaScript, but that's the Ajax-y wave of the future. So I write it when I have to. This week I needed to format a Javascript date as a MySQL-style date like 2007-12-08.
JavaScript apparently doesn't have a nice date formatting function or even a generalized sprintf. Another Javascript quirk is that the Date.getMonth() function returns 0-11, while the getDate() function returns 1-31. I'm not sure what the designer was thinking on that one. I came up with this function...feel free to use it in your code with or without credit:
function formatDate(date1) {
return date1.getFullYear() + '-' + (date1.getMonth() < 9 ? '0' : '') + (date1.getMonth()+1) + '-' + (date1.getDate() < 10 ? '0' : '') + date1.getDate(); } Friday, November 16. 2007Comet Holmes
I've been reading about Comet 17P/Holmes on SpaceWeather. Last night I finally went out to have a look. Once I was out of range of our annoying streetlight and the neighbors' lighting, I was able to pick the comet out with the naked eye. It's just a smudge in the sky, but apparently that smudge is bigger than the sun.
I got my camera gear out and braved the cold to take a few photos. This one turned out OK. Now I just need a telescope and clock drive to take pictures like this. Tuesday, November 13. 2007Attack of the Beetles
The past couple days the Asian lady beetles have really been out in force. They are all over the outside of the house. At least they helped me find a gap in one of my window frames which I was able to close up. This is probably the most of these beetles that I've seen at one time...wonder if it has any connection to the drought. Perhaps they are flocking to my house exterior since there's a water source nearby.
Friday, October 19. 2007The (Mostly) Dry Turkey Creek
Last week I took a few hours off and headed down to the Turkey Creek. I've kayaked down there twice and hiked trails a few times, but this time my goal was to hike the creekbed. The idea came to me the last time I paddled there, as it was hard to get good photos while the kayak was moving so quickly. I figured that with low water I could wade and take my time with the camera.
It takes a steady day or two of rainfall to get the Turkey Creek to the optimal 2-4 foot paddling level. As it has been ridiculously dry here in western South Carolina all summer and fall, I was sure that I'd be able to walk in the creek. I arrived at our standard put-in, just below the Key Bridge. Normally the water is around the bottom of the steps (like this). This time the water was almost completely gone; there was just a trickle in the middle of the creek, far from the steps. I thought I'd be in for a totally dry hike, but I was wrong. Not too far down-"stream", there were spots where the creek was full from bank to bank, but not really moving. At the dry put-in I found several small pools, teeming with speedy water bugs. Didn't have much luck photographing them, but as I was doing it, nearby movement caught my eye and I spied a frog. It was an unusual brown color and fairly bumpy, but to me it looked more like a frog than a toad. It was a good photo subject, and from looking at my field guide at home, I think it was a cricket frog. From here I decided to start slogging down the creek. The water was fairly warm and mostly shallow. In general it was clear enough to see the higher ground, but every once in a while I'd have to cross a dark, deeper section. I started out by telling myself I wouldn't get deeper than my knees. Getting those wet, I decided not to get the shorts in the water. But it wasn't long before the pantlegs were a little wet. I eventually decided to not go deeper than my waist in order to protect my camera backpack. A couple times the creek got so deep that I had to find a fallen tree trunk to wade across and balance with my hiking pole. But I was able to get about a third of a mile downstream without getting my shirt or the camera gear wet. The creekbed alternated between rocks, gravel, and mud. The mud had trapped gases which got released as I walked, bubbles popping with lovely stagnant fragrances. Once I came across a nice section of what looked to be the same sort of jagged phyllite I saw last winter. I didn't see a lot of wildlife while I was actively wading. It is noisier than kayaking and perhaps my element of surprise was diminished. I managed to see a few turtles, lots of fish confined to the shallow sections, and I heard plenty of birds. However, as I stopped to take a break on a gravel bar, I was treated to four deer crossing the creek in the distance. Wish I'd had the camera ready for it. I stopped for lunch on another gravel bar. Most of the shoals were overgrown with vegetation, a testament to how long it had been since these bars were fully submerged. After I ate I watched a flycatcher in a tree and debated whether it would wait for me to put the telephoto lens on the camera. I decided to give it a try and of course the bird bailed just as I was ready. But that did prepare me to photograph the flash of yellow that appeared nearby in the same tree. The bird stayed just long enough for me to identify it as my first Hooded Warbler, but not long enough for me to get a decent photo. The blurry result resides at BirdSite for now. Still, it was great to see a new bird species out there in the middle of "nowhere." I got a little sloppy on my return hike/wade. There were a couple deep sections where I couldn't remember exactly where I had come down, so I had to guess heading back up. At one section I was walking along a submerged tree trunk and slipped, soaking my shirt and getting the bottom of the backpack wet. Fortunately I had recovered without getting any of the lenses wet. Grateful, I resolved to be more careful for the rest of the walk. I arrived back the steps in good order and headed back uphill. The last time I was here there was unfinished trail bridge just below the Key Bridge. It looked finished, so I hiked up to it and was able to walk out on it. It's in good shape for future hiking and mountain bike traffic. And so ended my little adventure. It was interesting to travel the creek on foot, but I think I still prefer to paddle it! Photo Album Tuesday, August 28. 2007Improving upon Rails' validates_inclusion_of
I'm fairly new to the Ruby language and the Ruby on Rails framework, but it worked nicely for quickly building my website BirdSite.
I was using validates_inclusion_of fairly regularly to make sure the data in my models was valid. But then, watching the development log, I noticed extra SQL queries being made when I accessed my main model. It seems that validates_inclusion_of was forcing the model to make queries to the related models even when I didn't need data from them. Some Googling led to a blog post that did the validation a different way. It worked well, until I added the code to a new model today and it broke. The code was translating the model field name into a string from which to call the model itself. But the code assumed that the model would be a single word. I added a change to strip the spaces out, and it worked again. I contacted the company that hosts the blog and they confirmed that it was a problem, and they didn't know of a nicer Ruby way to correct it short of dropping the spaces with search/replace. They updated their code. I'm glad I could help out. It really works better than the standard validates_inclusion_of. Tuesday, August 14. 2007Rails acts_as_ferret without DRb
I wanted to add a search feature to my Ruby on Rails application BirdSite. There is a plugin called "acts_as_ferret" which allows Rails applications to use the Ferret search engine (based on Lucene).
Using this tutorial, I was able to get search up an running. It worked great on my development system. But there was a warning that you needed to run the indexer using a DRb server instead of directly from the Rails app. This is because the index cannot handle multiple processes writing to it simultaneously. (I also ran into this problem using PHP with another engine called Xapian). I was hoping my new site was low traffic enough to avoid problems. Since I'm hosting it on a shared server, I can't run a DRb server there anyway. But I got my first indexing exceptions less than 24 hours after I loaded my stuff onto the live server. So I decided to try periodic indexing by a cron job. This would allow me to update the index once an hour, from a single process. The downside is that the search index is only updated hourly, but I decided I could live with that. The first step is telling your Rails app to not index the content when updating. My model already had a before_save method, so I added this code:
# in the model def before_save # other stuff goes here # disable automatic ferret indexing...move it to a cron job self.disable_ferret(:always) end Then I had to create a rake task which would build the index:
# ferret_index.rake desc "Updates the ferret index for the application." task :ferret_index => [ :environment ] do | t | MyModel.rebuild_index # here I could add other model index rebuilds puts "Completed Ferret Index Rebuild" end This task is simplified: I'm telling it to rebuild the entire index each hour. I'm guessing when my dataset gets big enough, this will be really slow. In that case I'll need to track all the model instances that got updated in the past hour and just index those. Finally, I needed a cron job to run the rake task, making sure to set the environment to "production":
cd /rails_app && rake ferret_index RAILS_ENV=production
So far this is working well, and I haven't received any indexing exceptions since. Tuesday, July 31. 2007Northeast Minnesota
Check the photo album
Well, I've been back a week, but it took that long to recover and get through lots of photos. I went up to northeast Minnesota for the BugGuide Gathering. I had a great time and it was fun to meet several of the BugGuide members I've known online for years. The meetup was at Wolf Ridge Environmental Learning Center, which was the perfect place for it. They are up a small mountain with lots of wilderness, but they've got a sizable meeting room with a PC projector and WiFi internet. One minute you're looking at moths attracted to blacklights and the next you're trying to ID it on BugGuide. Friday the 20th I flew up to Duluth. I didn't realize that I sat next to one of the BugGuiders on the flight from Detroit. I did a little sightseeing along Lake Superior on my way north to Wolf Ridge. In the evening we met up and chatted about dragonflies and damselflies with Kurt Mead and folks who were attending the Minnesota Dragonfly Gathering simultaneously with us. After dark we set up blacklights and tried to attract some moths to the Science Building. The first few moth arrivals were subjected to papparazi-like photography. It was quite a scene. Eventually with the arrival of more moths in various places and folks going to bed, the flash gun rate dropped to a less blinding level. I was excited to see my first Polyphemus moth. Saturday the whole group loaded up into several cars and headed for a boggy area between Finland and Isabella. It was the first time I've walked into a bog and it was fun. The mossy ground is squishy and in some places a footstep will sink just enough to flood your sandals. The bugs weren't as busy as we thought they might have been, but we still found several species of butterflies and a couple dragonflies. And I can't forget the deer fly that bit my knee. We moved on to lunch at a lake, my first of Minnesota's 10,000 lakes, or maybe the second if you include Lake Superior. At a creek with some dry brush, I did some photo hunting of beautiful red dragonflies, the white-faced meadowhawks. Just before we left I got a good photo. At the next stop we had to fix a flat on John VanDyk's car and I saw a female white-face. The final stop was the treat of the day, a beautiful large bog and a pond, with lots of damselflies. In the evening I got my first chance to try rock climbing on a very nice indoor climbing wall. That night we did some more moth blacklighting, but a cool breeze kept their numbers down. We did see a nice Laurel Sphinx, and some of the night owls were treated to views from Wolf Ridge's telescope and the sound of wolves howling in the distance. Sunday the group started to break up as some folks had to be on their way. But several stayed and did their own exploring of Wolf Ridge. I joined up with a former Wolf Ridge guide and a forest service worker. We decided to go canoe Wolf Lake. I agreed to let them paddle and I would take pictures from the middle of the boat. Despite being an experienced paddler who should have known better, I slipped on the dock trying to get in and soaked my pants and shoes. At least the camera gear stayed dry! I eventually got in properly and we circumnavigated the lake, not seeing any bugs due to the cool weather. But we did spot a pair of beavers. After the paddle we made an easy hike up Marshall Mountain, which gave us a view of Wolf Lake, plus Raven Lake and even Lake Superior, which was a little tricky to see, since the lake was the same color as the hazy sky. After lunch I went with several folks to Raven Lake, where I made a much better showing in the canoe and did some paddling myself. Kurt Mead took the bow and captured a few damselflies right from the boat. He did a good job explaining how he made his IDs using a hand lens and a well worn field guide. Later a small group of us hiked into the wetlands on one side of Raven Lake. That evening, I enjoyed a great meal with Kurt and his family and a few other Odonata enthusiasts, and spent the night in a treehouse! Monday I was up a little early, driving up Highway 1 looking for moose. I struck out in this endeavour, but I did get a few bugs on a poorly maintained walking trail. From there I started my run south, stopping at points along Lake Superior. First I drove up to the Palisade Head cliffs. It's precarious up there (reminds me of Jumping Off Rock), but I was careful and got some good photos. Then it was down to the Split Rock Lighthouse, a very picturesque subject, though it's probably a better photo in winter with snow all over the place and fewer tourists climbing around. From there I went to Two Harbors and had a chance to shoot the lighthouses there before returning to Duluth and the flight home. Great trip!
« previous page
(Page 2 of 17, totaling 167 entries)
» next page
|
CategoriesQuicksearchArchivesSyndicate This Blog |