Articles

Twitter me this

If a tweet is uttered with no followers, does it make a peep? I'm getting going with Twitter on http://twitter.com/d2h.

67. Rush - The Ruby Shell

rush is a replacement for the unix shell (bash, zsh, etc) which uses pure Ruby syntax.

It combines the power of unix with the elegance of Ruby.  

Simple Expense Tracking with Google Docs

As my family prepares for our pending Disney trip, I’m thinking about clever ways to take advantage of my wife’s iPhone. One of the things we’ve done is budget the trip based on a few simple categories of expenses. There’s a lot of ways to track expenses to budgets, but I’m particularly happy with how this worked out using Google Documents and the iPhone.

RTeX 2 Preview 1 Released

I’m happy to release RTeX 2 Preview 1 (v1.99.0), now available as a gem from RubyForge. RTeX can be used as a plugin with Rails 2.0.1+.

History

In 2006 I released a Rails plugin, Rtex, used to generate PDFs via the LaTeX typesetting system. It became a popular choice for people looking for a more advanced alternative to PDF::Writer, especially for larger documents.

Wiebe Cazemier joined the project in 2007, helping to improve the plugin and fielding patches and bug reports.

The Paris Project

One of the nice things about the last two and a half years has been working from home. You avoid 90% of the dilbert-style office drama, and the commute is hard to beat. But the nicest thing about working from home is that, strictly speaking, I can work from any home, not just our little place.

So from July the 4th till the end of the year Anika and I will be living in Paris. You know, this paris:

Now running on Passenger

Today I had a few hours to spare and decided to try out Passenger. This blog is hardly a high traffic website, but it has some crazy RewriteRules that I figured would test the limits of the module.

Everything appears to be working perfectly, and it took less than 5 minutes to set everything up. I’m seriously impressed at how simple this was. I’ll confess to being skeptical at first, but so far the package lives up to the promises on its website.

Rails Chops: Layouts and Flash notices

Please view in full screen:

The silent majority

I had a great time on the West coast recently with stops in Santa Barbara and Palo Alto. What always surprises me at events like these is the huge number of people I meet that are doing cool things with Rails that I've never heard of. The kind of people who are just really happy to be using Rails and happy to build businesses with it.

Tropa Da Elite Trailer


Shutting Down Windows from Ruby Code

Someone recently asked how to shut down or restart Windows from their Ruby code. Windows provides an executable, "shutdown.exe", to accomplish this. Execute this command from your script with the appropriate parameters and you can log off, shutdown, or restart the OS.

Parameters accepted include, but are not limited to:


-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-t xx Set timeout for shutdown to xx seconds
Articles | Rails Fire

Articles

Multiple actions on one form

By using form tag we can define a action where we can submit the data and proceed further.
Now there are multiple submit button on the form and each required different action. So how to do that?
I found one easy solution for the this.

.....

function [...]

More Rack::Shell goodies for all Rack worshippers

Rack::Shell got a lot of attention lately and I received some feature requests/ideas from great ruby hackers. Daniel Neighman, currently working on Pancake, pointed me towards Bryan Helmkamp's rack-test. This awesome piece of code is now used by racksh to simulate HTTP requests to your Rack application. Yay!

hash method in ruby

I did not know about hash method in ruby object and I paid a heavy price. While developing admin_data plugin I proposed to pass certain values in configuration like this.

ensure method in ruby

Here is code.

def hello
    yield
  ensure
    puts 'in ensure block'
    true
end

puts hello { puts 'world'; false }

I thought if I call hello method then the final returned value will be true. The common ruby convention is that last value gets returned. In this case the very last value is true so I was expecting true to be the returned value.

If I execute above code this will be the output.

Clearing out Rails Sessions

As I’m sure you’re aware, Rails can be told to use ActiveRecord (and hence the MySQL database) to store session data. (New Rails apps use the cookie store by default—See the rails sessions guide for more info on both.)

However, this session data is never deleted, which means your session table continues to grow and grow forevermore. Your old sessions are left stored in the database, and although the table is indexed to help with finding sessions, it will eventually fill the disk up.

Retrospectiva: Open Source Project Management Rails App

retrospectiva.pngRetrospectiva is a new open-source project management tool built as a Rails application. It's interesting from two angles: first, as a project management tool, as it was designed; but secondly as a large, well built Rails 2.3 app to learn from.

Jammit: Industrial Strength Asset Packaging for Rails Apps

jammit.pngEarlier this year on Ruby Inside, we wrote about Sprockets - a Ruby library from 37signals that could take the various JavaScript files used in your project and compress them down on the fly into smaller portions to be more easily sent over the wire.

Use of Dirty Objects

Uses of Dirty Objects

Developer have some confusion that how they can get the previous value of the field after update.
So here the rails has a way called Dirty objects.

You can found Module Dirty in rails/activerecord/lib/active_record/dirty.rb
This is just for track unsaved attribute changes.
There are few methods in dirty module as below
* Changed
* Changed?
* Changes
* Included
And it has some constants

Mi-Fi 1.1 in AppStore Now and what I learned along the way...

During 360idev (Sept 27-30) I wrote a small app to check the battery and connectivity level of my Mifi Card. I didn’t think many people would have an iPhone and a Mifi card. The iPhone is already 3g, but effectively there is not tethering allowed and the AT&T network is crapy.

Expiring an entire page cache tree atomically

As you’ll all know, Rails has page caching baked right in – the first time an action is hit, it writes a html file of the result to the filesystem. Subsequent hits are served direct from the html file at high speed by the web server without ever involving your Rails app.

Expiring the cache is just a case of deleting the html file. But what if you want to expire an entire tree of cache files? Say you change something in a header or footer, so every single page needs expiring at once.

Getting MacRuby’s compiler to work | Rails Fire

Getting MacRuby’s compiler to work

MacRuby's logoThere is major news in Rubyland today. MacRuby’s team just released their fist beta of version 0.5 (an experimental, still incomplete version of Ruby), which brings JIT, removal of the dreaded GIL (Global Interpreter Lock), native threads, GCD (Grand Central Dispatch) for multicore computing, and a whole new set of features found in the release announcement to the table.

The most important new feature is the presence of a compiler. That’s right, thanks to this release, Ruby code can now become highly optimized executable code. How awesome is that? I can sense that you’re pumped by this news, so why not head over to MacRuby.com and download the installation file for yourself? After you’ve done that, the next thing you’re going to want to do is run a small test like the following:

$ macrubyc world_domination.rb -o world_domination
Can't locate program `llc'

Oh noes! llc is a tool that ships with the LLVM (upon which MacRuby is built), however it’s not included with MacRuby’s installer (it will be in the future). But fear not my friends, there is a solution:

$ svn co -r 82747 https://llvm.org/svn/llvm-project/llvm/trunk llvm-trunk
$ cd llvm-trunk
$ ./configure
$ UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make -j2
$ sudo env UNIVERSAL=1 UNIVERSAL_ARCH="i386 x86_64" ENABLE_OPTIMIZED=1 make install

If your machine does not have 2 cores, remove the -j2 option from the fourth line or adjust the number accordingly.

The compilation phase may take a couple of centuries, depending on your machine’s speed, but it should eventually build the LLVM. :-P llc will be placed in your PATH, and you’ll finally be able to compile Ruby code and obtain an executable to help you carry out your world domination plans.

$ macrubyc world_domination.rb -o world_domination
$ ./world_domination
MUAHAHAHAHA!

<!-- Social Bookmarks BEGIN -->

<!-- Social Bookmarks END -->

Images: