Entries Tagged 'Ruby' ↓

CoreData - A Great Tutorial

If you think you are ready to sink your teeth into Core Data, you should definitely start with Scott Stevenson’s tutorial.

Granted, you may want to use XCode 2.x for the tutorial, since that is what the tutorial is in. The differences between Interface Builder with XCode 2.x and XCode 3.x are pretty huge. The workflow is very different. (not to mention the interface, no pun intended)

I myself am still getting acquainted with XCode 3.x and my new Intel-based MacBook is in the shop, so I’m on the reliable old G4 iBook today, so it is an exercise I can work on in the interim.

Although you don’t need to be an expert at Cocoa Bindings, and there’s a strong chance you’re not. (not many people are) You will want to at least have covered the frustration of trying to work with bindings a little bit before sticking your nose into Core Data. And, as always, I will say if you’ve worked with Ruby on Rails and Active Record before, you will find Cocoa, Cocoa Bindings and Core Data a little less frustrating, but don’t expect it to be the same thing. It does still work like ORM (object relational mapping) so having a basic understanding how CRUD (create, retrieve, update, destroy) applications work with databases will help you a lot.

Install Oniguruma on OS X !

You may have tried unsuccessfully to install the Ruby Gem ultraviolet or the gem it depends on, textpow, and if you did, it likely failed mysteriously. Well, you first need to download and install the Oniguruma regex library. These instructions should work on almost any *nix with GCC, as well as OS X 10.4 and 10.5 !First, go to  http://www.geocities.jp/kosako3/oniguruma/ and download the latest version of Oniguruma. (as of this writing, 5.9.1) In terminal, cd to the directory you downloaded the tarball to.Un-tar it: tar zxf onig-5.9.1.tar.gz Change to the directory of the un-tarred stuff:cd onig-5.9.1 Configure it, in most cases, just add the PATH you use, normally, /usr/local ./configure --prefix=/usr/local After that’s finished, sudo make and then,sudo make install
 Now, you can install that oniguruma gem with no trouble! Same goes for textpow and ultra edit. 

RubyCocoa is Real

With the recent update to OS X Leopard, 10.5.2, RubyCocoa has been updated (0.13.2) as part of the update as well! This shows that Ruby is being taken somewhat seriously at Apple. (I say somewhat because there is not a bigger effort afoot… but it’s good and getting better.)Now, I just encourage more people to try it and use it, so that it gains more momentum and attention. This in turn will convince Apple management to put more into it! 

Ruby Gem BlueCloth not working? Not found? Not installed?

Some Ruby Gems are better than others. Some are great once they are working, but how to get them working is not always obvious… BlueCloth (the Ruby implementation of Markdown) is one of these. Unfortunately, simply doing sudo gem install BlueCloth is not enough. The BlueCloth home page, a Trac site, does not tell you squat about it either. So what do you do? Well, as with any gem that doesn’t just install easily and work with a simple require 'gem_name_here', the first thing to do is look in the gem’s directory!!If you do not know where your gems are, at the command line do gem environment and you will see the path to your gems. Copy that path and cd to it. Then do ls and you will see you’re still not there. cd gems will get you into the proper directory for the gems.Once there, you will notice that each gem has a directory with the name and version number of the gem itself. In this case, cd BlueCloth* should be enough to get you into the BlueCloth directory. If you do have more than one version, you will need to add the version number to that.Once inside the BlueCloth directory, you will see a README and install.rb, first read the README. Hmmm… it is not real clear language, but it does indicate you will need to run install.rb. OK. In the same directory, run ruby install.rb and you should see a few lines:Cloth Installer Revision: 1.3 Testing for the StrScan library...foundTesting for the Devel-Logger library...foundInstalling   If you get any error message, you either need to use sudo to do it, or you just do not have enough permissions/privileges on that machine.  If you get no error message, then you can now use BlueCloth for converting Markdown to html!In any normal Ruby code, simply be sure to add:
require 'rubygems'
require 'bluecloth'
 In a Rails application, simply add the second require line in application.rb and you will be ok to use BlueCloth from within your Rails application. You can actually use both require lines there, but the require for rubygems is just taking up space on the page at this point. If Rails is working, then RubyGems has already been required somewhere else! The beautiful thing is, BlueCloth is easy to use and very effective!  One more thing… this information is true on Linux, OS X, and any *NIX installation. On windows… I have no idea. Personally, I cannot see why people go through the pain of programming on windows, except that it can pay the bills…? 

A Higher Level : What Ruby Represents

There is a pretty decent interview with Russ Olsen on his new book on design patterns in Ruby. In it he focuses on what is different and the same in Ruby design patterns. I’ve been thinking a lot about Ruby and what it represents, particularly when I’m (sadly) not working in Ruby.Mr. Olsen talks about how Rubyists just don’t bother with the factory patterns. As I understand it, the factory pattern has to do with object oriented classes that are called abstract classes and are developed as foundations for other classes. They’re then used to be sensible defaults that make descendent classes have lots of built-in goodness.Mr. Olsen wonders aloud why Rubyists don’t use them much. Well, it’s simple. Ruby itself has it built in for the most part. Ruby makes things clean enough that we don’t need to have our hands held and be told to stand in a straight line by somebody else most of the time. Sure, we make mistakes and duplicate things, but we can. And we can still make things work and get things done. Ruby also makes it a little bit pointless, since there are no truly private classes in Ruby. We can get at the core of anything and change it. There’s no company locking you in or limiting you with their private API. Ruby culture leverages the openness of the language as well as the old Perl attitude of “good enough for now, we can improve it later if needed.” 

Psst… hey!

Ruby also represents a new level of abstraction from the machine. These days, processing speed and power are at a surplus in most situations. There will always be some need for high-performance, low-level programming, but even there, what was once done in assembly language is now done in C or C++ and will someday be done in better languages. (better for humans, that is) With Ruby and modern computers (which will only continue to improve) most of us don’t need to worry about mucking around with all that low-level crap. Quite honestly, we should not be worrying about that low-level stuff unless it truly is warranted. Ruby culture here too is about knowing that it may not be the fastest, but knowing that we can have a working solution fast and have fun doing it.Ruby gives you a chance to be concise and expressive, while still thinking in human terms more than with many other languages. Python is close to this as well, but not in exactly the same way. Interestingly, there doesn’t seem to be any real contention or rivalry between Ruby and Python, or Perl for that matter. They happily coexist as different ways of <em>getting things done</em>.Ruby does deserve all the buzz it’s getting. Believe me, programming often turned me off completely when I was younger, but not because I was younger, because it was more tedious than it needed to be. Programming should generally be about being lazy. Making a machine do things for you. Ruby makes it intelligible enough to wrap your head around what you are doing so that you <em>can</em> do it.I’ll admit, I like to do quick and dirty with Ruby as well as any old Perl programmer would do. Yes, I’m talking duct-tape and quick-drying super-glue. You can optimize and refine later. Get things done today!And by the way, you don’t have to learn design patterns first. Ruby will naturally get you using a lot of them without thinking, but if you find Ruby is your cup of tea, <em>you will want more…!</em>

Ruby, Apple, and the year 2008…

It’s a bold new year for Ruby. The recent release of Ruby 1.9 (though it’s still not a production ready release), the inclusion of Ruby as an officially bundled item in OS X 10.5 (though 10.5 still needs a few dot-versions to reach production release itself), Rails 2.0, a whole plethora of new Ruby books…The Ruby year is going to be a good one. It may end up being a bit frustrating when the push to migrate to 1.9 actually does come, but shouldn’t be too bad.On the book side, there is a very interesting Ruby Design Patterns book as well as a few others, such as the Practical Ruby Projects book, and the FXRuby book.Now, we just need a RubyCocoa book, a Ruby Qt, a Ruby Tk, and a WxRuby book.We also need a Ruby game development book. I don’t have any interest in Lua, and Python is the Ruby for people who like the way Python does things.Myself, I’m working on a Cocoa wrapper app for RubyGems called Gem Commander. I’ve already got a proof of concept working app, but it’s slow going dealing with Cocoa and Objective-C after doing Ruby so much. Here is the logo for Gem Commander… Gem Commander logo You see, Ruby is just so expressive and feels modern. Objective-C and Cocoa (and AppleScript, while we’re at it) all definitely show their age after coming from Ruby. The method signatures in Objective-C are conceptually very cool, and the whole thing beats the hell out of C++ or Visual Basic, but the naming of methods and the way things work is sometimes just not graceful at all. (especially, as I said, after doing things in Ruby)Even RubyCocoa is just a dog in comparison to straight Ruby. It does present the opportunity to mix good Ruby expressiveness in to things, but at the cost of still needing to navigate through Apple’s ridiculous documentation. Apple really really really could learn a lot about documentation in the modern world from the Rails crowd. (minus the people Zed Shaw bitches about… ).On the subject of Apple, AppleScript itself is really a dog these days and is overlooked or under-attended by developers. Apple really just needs to overhaul the whole damn thing in favor of serious Python, Perl and Ruby scriptability out-of-the-box. Then, you would see a real explosion of cool stuff. 

First Book With Rails 2.0 : The Rails Way

The long awaited book “The Rails Way” is finally out, and it’s chock full of good stuff and even includes (slightly pre-release) coverage of Rails 2.0 already. Aside from the CD Baby boondoggle, Obie IS a Rails Core guy, ( I think… ) so he should know a thing or two about a thing or two.

The only drawback: the Rails Way is a big honker. Back breaker. The same problem with Hal Fulton’s classic “The Ruby Way”, the book is TOO BIG and heavy. I really wish publishers would get smart and publish these things in smaller volumes with numbers on the spine. It would be a lot easier to carry around and they’d quickly find out what parts of a text are really driving sales…

The Problem With Cocoa Programming

I’m a huge fan of Macs, no doubt about that. But… Cocoa programming leaves a lot to be desired at times. Continue reading →

An Interesting Ruby One-Liner To Ponder

Here’s an interesting Ruby one-liner to ponder:


0.step(100, rand) { |x| puts x }

Imagine how useful this or some derivation of it could be in a game, or any situation where you want a timer, but not one that seems too regular and even…

OS X 10.5.zero Leopard Opinion, Finalized

Well, I gave Leopard a day; One whole day of mostly lost time trying to get things working for developing again. Granted, Continue reading →