-
- Ruby: Extending classes and method chaining.
-
Once you start fooling around with the Ruby language you really do get hooked on just how powerful it is. I was disappointed when I first found out that the String.capitalize function only formatted the very first letter of a string to a capital letter as this is undesirable when you are formatting something like a street address. Not to worry though, extending the String class is easy in ruby and writing the function to do it requires only one line of code!
class String def capitalize_each self.split(" ").each{|word| word.capitalize!}.join(" ") end def capitalize_each! replace capitalize_each end end puts "hello WORLD!".capitalize_each #=> "Hello World!" s = "6825 W. GALVESTON ST." puts s.capitalize #=> "6825 w. galveston st." puts s.capitalize_each #=> "6825 W. Galveston St." puts s #=> "6825 W. GALVESTON ST." s.capitalize_each! puts s #=> "6825 W. Galveston St."Pretty nifty eh? If any one can show me how to rewrite the function as a destructive function please comment because I’m stumped.
Update:
Thanks to Assaf’s comment I was able to write the destructive version of capitalize each.
-
- Ruby: Creating destructive methods.
-
Here’s a basic example of using Ruby to create a class with destructive methods. Though this is not as practical as just typing the actual mathematic operations themselves. It does illustrate how destructive functions work and how to write them. Note the ‘return self’ in each of the destructive methods. This allows you to perform the method chains, without it the method returns a fixnum by default and the method chaining raises an error. If anyone knows of a DRY way to perform this let me know.
class Calculator def initialize(value) @value = value end def multiply!(value) @value *= value return self end def add!(value) @value += value return self end def clear! @value = 0 return self end def calculate puts @value end end c = Calculator.new(10) c.add!(2).multiply!(4).calculate #=> 48 c.clear!.add!(5).multiply!(4).calculate #=> 20
-
- Transition to Dreamhost.
-
Well now all of my current sites are hosted on Dreamhost. The only way to go from here is to get my own box later on down the road. Since I had to upload some files all over again I figured I’d install a new version of the textile 2.6 plugin that allowed support for the Geshi syntax highlighting engine. Let’s do a quick test to see if it worked.
def hello puts “hello world” end 3.times do hello
Update
Obviously the Geshi system is getting cleaned up by the Textile plugin. I’m still confused as to why but at this point I may just have to live without Geshi becuase I already know I can’t live without Textile!
-
- Fast CGI to be Revamped on Apache.
-
Whoa! Apache decides to officially revamp Fast CGI support. Ruby on Rails is starting to influence and revive life into once dormant technologies! Sounds like mod_fcgi will be revamped as mod_proxy_fcgi.
-
- Easy File Uploads with Ruby on Rails.
-
This is nifty… check out this file_column behavior for Ruby on Rails. Wow that looks damn easy.
-
- DontTrustThisGuy.com - Design in Progress.
-
If you’re reading this your feedback is required. I’m redesigning my blog by heavily hacking up Squible to the point I probably won’t be able to upgrade past 2.5 alpha. Oh well so be it. Here’s what I’m doing.
The color scheme
I’m trying a salmon (pink) and blue color scheme. I wanted to try something I wouldn’t normally do and I kind of like it even though it creeps me out. Normally I’d just do black and grey so this is a refreshing change.
The header
The header of the page is designed to look like a torn up news paper an there is a live flickr feed that has been styled to resemble polaroid photos. The idea was to make the site resemble a dirty torn up unreliable newspaper to make it even less “trustworthy”.
The content (style)
Overall the site is using serif fonts to resemble a newspaper rather than more screen friendly fonts such as Arial, Verdana, etc. The content is using the less is more approach. There are just some lines and slight background touches to spruce things up a little but but otherwise from that the text is text and nothing more to take your eye away from that fact.
I’m not even close to being done.
I still have to style the interior footers and comments so stay tuned but let me know if you like the direction.
-
- Site broken; me put back together soon.
-
Yeah I messed things up. Now I’m too tired to finish. So much for live testing.. oh well it’s a personal site I can do whatever I want.
-
- Upgrade: Wordpress 2.0 (rc3)
-
I lost a couple of comments today but thought I’d give my blog a Christmas present by updating to the latest build of Wordpress 2.0. Unfortunately, the upgrade script did not work as planned so I did a lazy dump, dropped all of my tables, and reinstalled wordpress from scratch. Here are a couple of key improvements I’ve noticed:
h3. AJAX in the Admin
The new administrative interfaces breaks the nicely styles Tiger Style Interface plugin developed by “Steve Smith”:http://www.orderedlist.com . However the AJAX widgets and new stylesheet for the default worpress admin are a welcome addition.
h3. File uploading given some detailed attention.
You can now upload files directly in the post:
A nice AJAX file upload block beneath the content window allows you to manage and upload images for your post. You can even drag the image into the content window.
The image management is actually incredibly robust automatically generating a thumbnail and then allowing you to delete, or browse any photos uploaded in the system during the editing process. Even cooler, clicking on a selected image brings up the option to insert it as a thumbnail that is linked or not linked to the image or the content page automatically generated for the given file. It’s something you’ll just have to try out for yourself but I’m very impressed with the techniques used in the administrative area of wordpress 2.0.
h3. Squible doesn’t break on WP 2.0
It looks like the install of Squible 2.5 is running without any modifications needed after upgrading to Wordpress 2.0. So there is certainly no harm in installing Wordpress 2.0, especially considering they have written documentation for upgrading your customized themes.
h3. Wordpress the benchmark for CMS?
I think Wordpress is definitely the benchmark for how all other CSM apps will be judged. The community and features supporting the system are astounding. It should be very interesting to see how Typo developers in the Rails community as it already has an AJAX derived interface but lacks some essential file management that Wordpress 2.0 has just launched. Also the plug-ins and community for Typo still is much smaller so it’s doubtful you’ll find a Google-Analytics plugin for Typo the day after google announces it. Never the less slowly but surely it’s getting there as well.
-
- Blogging in Style: Beseku
-
I recently stumbled across another excellent blog. In this case, it’s a blogfolio, showcasing portfolio of work in a blog format, for Ben Sekulowicz-Barclay. I think Ben has don an excellent job keeping it simple and clear. I love the lime green / dark grey / white color scheme but what makes this site really interesting is the fact that there’s no navigation whatsoever. No tags, no category listing, no archive lists. Just content. I really like it because his design makes it work. It only takes a few minutes to realize how easy it is to find anything on his site.
Check it out: Beseku
-
- myGoogle?
-
Google is everywhere these days so changing their homepage might not be as big of a deal as it sounds. After all, when is the last time you actually went to Google without already typing in your search phrase via another web form or tool?
Maybe that’s why Google has modified the extremely minimal interface that made them stand out from Yahoo and Altavista. Google initially attracted people because it was so straight forward. It was clear, simple, and concise. Unlike Yahoo where users would go and become bombarded by all sorts of news, and other various resources; Google only had a search field and a logo. The choice to users was clear. If I need to search I can use Google. Yahoo in contrast does everything.
Although there were many other factors that later contributed to it’s success, the minimalist interface was the key distinguishing characteristic that set Google apart. Changing this interface is a dramatic move by Google. Of course, they’ve done it somewhat discreetly. They initially announced that you could customize your Google homepage but didn’t change it on you. Now however, they have taken the liberty to already add a handful of modules to your homepage for you.
AJAX takes over.
When you look at how Google has executed the homepage modules you might think they’ve done it quite well. From a developers perspective it’s pretty nifty. You can drag and drop modules reorganizing them however you want very easily. You can also add modules with a slide menu that comes in to the left of your screen. But is it really something people will use?
The verdict?
I’m still not sure if this a good idea. As I prefer Google becuase of it’s simplicity; the thought of transforming Google into another Yahoo seems a little disconcerting. I’m almost more comfortable removing all of the modules from my Google homepage than keeping them on there. After all, the modules are a bunch of tools that I already have elsewhere so I’ll probably never use any of the modules. My apple dashboard gives me weather and newsupdates faster, and I can use del.icio.us for all of my online bookmarks. What’s your take on the whole thing?
