I found this and thought it might be useful to someone. Paying it forward.
This is a info post for people having problems. Generally Ruby is great, but due to some old development I was doing, my gems got screwed up. The best way to fix this for me meant reinstalling OS X Leopard. This might have come from different package managers running at the same time, like Fink and MacPorts, but ultimately, I had to clean things up.
In addition to a fresh install, I also had to manually remove Ruby from seven locations on my hard drive. They are
Now that this is done, I’m going to reinstall by
- installing MacPorts from their download site
- installing Ruby via MacPorts (“sudo port install ruby”)
- installing a tar of rubygems and install manually
Likely queries to end up at this page are:
- How do I remove Ruby from OSX
- How do I remove Ruby from OS X
- Reinstalling Ruby
- Reinstalling Ruby Gems
- Gems screwed up
Gregg’s “Speeding up Ruby, without the Rails” Presentation
He points out that the C library stuff is going to cause blocking, because Ruby’s threading manager doesn’t know when it can stop execution. He demos this with mysqlplus, showing 10 queries with the blocking driver, and then showing mysqlplus which is the non-blocking driver. 10x speedup.
He points out dbslayer, which sits between processes and MySQL, and passes JSON out to the processes.
Starling (which uses memcached) is a good tool for job queueing. Looks like it sits on a single server, and serves up jobs when requested. He demoed putting integers into the job stack, could we put whole objects into the stack?
“What if I can’t find a C library to do what I want?” — use Ruby Inline. It lets you embed C code *directly* into Ruby.
Also, he is talking about ruby-prof, which is for profiling Ruby code.
gem install ruby-prof
Very nice stuff, but interpreting the output definitely requires some knowledge. One neat trick is that if you
You can start and stop the profiling so that you only get data from the parts of the code you’re interested in. Also, with this technique, you can easily output HTML formatted and linked code.
Interesting optimizing trick
is faster than
@var + ” ” + @var2
because method calls are expensive, and the plus signs are method calls.
Another pro-tip: if you’re doing a switch-case, put the most common option at the top of the list — it cuts down on the number of compares that it will take to find the desired option.
In Rails 2.2, there’s a new function called “memoize”, which will automatically handle memoizing, so you don’t have to do a
Don't use .nil? calls, because method calls are slow.
are better choices.
a, b = b, a # Nice trick for swapping two values
Link love for Gregg: http://www.envycasts.com His presentation style is excellent, and I guarantee you will learn at least one thing you didn't know before.
http://www.railsenvy.com/rubyconf/ This link has more info from his presentation, and source material
Thursday AM Keynote by Matz
This is Matz: http://en.wikipedia.org/wiki/Yukihiro_Matsumoto
He’s talking about his love of languages, and why he got into Ruby.
He’s addressing some of the criticisms, that it’s slow, poorly implemented, embedding issues…he says the list of complaints goes on forever.
But, now he’s talking about why is Ruby good. He says people say it’s enjoyable, that Ruby made programming fun again.
He says he got into BASIC in 1980, and is talking about his problems with it. He says that one thing was the lack of being able to define data types. Everything is predefined, and you can’t change much.
He is talking a bit about LISP, and says some good things about it. He then complains about the parentheses in LISP, then puts up a slide that just says “No.”
He says he likes the aristocracy, as long as he is in power. BASIC gives you no power, LISP gives you full power. But, the problem is that at both ends of the spectrum, we lose popularity. It’s all about balance. You don’t want to go off the cliff of power with LISP, but you want to be able to be near the edge of the cliff — where BASIC isn’t.
He’s talking about why people choose Ruby. When he asks how many people choose Ruby because of Rails, about 60-70% of the room raises their hand. Matz points out that Rails is basically just a DSL for turning Ruby into a web language. He also points out that they are not at RailsConf, they are at RubyConf. This gets a laugh.
Again, talking about LISP, he says it’s a good DSL.
“There are under one million professional Ruby developers now, and we’re projecting there will be four million plus by 2013” — Mark Driver, Gartner analyst
Matz says “The future is bright…too bright maybe. Beware commercial success” He says, right now, we have the community and enthusiasm. In the coming years, we’ll have more money and more job titles. With these resources, come better implementations of Ruby. He says some of these are here now, but there will be more to make Ruby faster, more feature rich, and providing more satisfaction to us, the developers. He also says one of the great things will be all the new developers who are coming to Ruby, and he says “Welcome them, nourish them”. He says there are people who learn Ruby as a first language, and they go on to become great programmers. [Tim: I wonder what happens to people who start in Ruby, and then see C++]
He says he loves us all.
I’m here at RubyConf with some of the Cloudspace team. Also, Corey has come in from North Carolina, gracing us with his presence, and his beard.
I’ll probably be posting from some of the sessions as I go. Long posts will be on this blog, short things and ‘overheards’ will be on my Twitter.
If you’re here, get in touch and say hi. 😀
As a follow-up to yesterday’s post about Matt Williams’s presentation on Ruby and Arduino, here are some videos, slides, and notes from the ORUG site.
You absolutely must check this out. The field of robotics is going to play such a massive role in all of our lives over the next few years, and this is the ground floor.
Just got back from this month’s ORUG, where Matthew Williams gave a presentation on using Ruby to control an Arduino. Matt is a very natural speaker, and the presentation was great. He even demoed a bartending robot he built, which should be featured on Make very soon.
I took notes during the presentation, and they are as follows, with links where possible.
Physical Computing with Ruby and Arduino
Arduino is an open-source board
There’s Bluetooth Arduino boards
There’s an Arduino board that was developed in a circular shape. People have combined this with conductive thread and sewn it into clothing. Someone even integrated this with some LEDs into their clothing and made a shirt with turn signals for biking.
Matt showed a video of a Wii nunchuck integrated with an Arduino, hooked up to some servos, and made a robotic puppet that works just by moving the nunchuck (not the control stick, just the accelerometer motion).
There’s also a YouTube video with someone who built a 1-wheel Segway-esque skateboard. Matt claims there are only about 50 lines of code controlling this device.
Matt says that the Arduino Google Group is fantastic.
[Tim: The Arduino IDE looks a *lot* like the Processing IDE (the Java-based graphics language).]
RubyToC – Ruby To C project; converts your Ruby code into C++, then compile it into Arduino bytecode. Then, there are Rake tasks which will load it onto the board for you. Most — but not all — of the Arduino API has been ported to Ruby.
digitalWrite | digitalRead
analogWrite | analogRead
serial_print | serial_read
He mentions a slick trick for controlling the 7-segment LED displays. Since there’s 7 segments, you need to set 7 values separately, OR just create an array of those, and set them all with a single assignment.
Coming soon to RAD framework:
- Arduino Simulator (for testing)
- Better RubyToC support (there’s a few hacks required because ToC isn’t perfect)
- More “out of the box” support
- OLED displays
Shields are boards that can be plugged directly on top of the Arduino that add major new functionality.
- NYCResistor.com built a device that has sliders, like an audio mixing board. I bet it goes up to 11.
- 802.11 addons also exist
- Controlling motors
- There’s a $30 “ping” sensor from Radio Shack that detects distance in *inches*. Basically, you can add sonar to your Arduino.
- OLED touchscreen
- Pin visualizer — lets you debug pin outputs easily, shows you the voltages coming out of the board. Great for debugging. No one is sure if the code for these (debugging) takes up space on the Arduino in place of your code
Cheaper versions are available, but they either have components removed, or you must assemble it yourself
Make published a “get started with Arduino” kit, about $80, includes project info, the Arduino, extra parts. Most of the parts required for the project are included in the kit.
Barduino – DRINK MIXING ROBOT (created by Matt, who is clearly demonstrating his aptitude as a proper geek)
He used windshield washer pumps, $9/each
Matt created a DSL for describing drinks
drink ‘Screwdriver’ do
serve_in ‘Highball Glass’
Matt mentioned a hack, some functions that accept only one param will get converted (by RubyToC) to functions that accept none, so, the following line fixes it
foo = pump + 0 /* This is the fix */
For more Ruby Arduino…
RubyConf 2008, Friday, 10:25 – 11:05, Room 3
Greg Borenstein — author of the Ruby Arduino framework — is presenting
Can you “brick” an Arduino?
Not via code, but you could put too much power into it and fry it. Matt thinks there’s a little surge protection on it.
Can you sync Arduinos?
He’s seen something like it, and thinks that the serial comm lines would make it fairly easy to do.
Here’s a neat trick, if you’re working with Ruby. Ever wondered how to get a list of all installed gems?
At the command prompt, type
sudo gem server
Once you’ve done this, go to http://localhost:8808, and you can see all the Ruby Gems installed, along with info and documentation about them. Awesome!
Hat tip to Matt