Posted about 1 year back at Simplistic Complexity - Home
As a web dev, you may spend some time messing with DNS and overriding it. Though, it can get annoying when you can't get things back to the way that mere mortals see things on the internet.
lookupd -flushcache was a big tool in my arsenal in Tiger. But Leopard put a rightful end to lookupd, but left us without our known way of flushing the cache.
For the last couple of weeks its been pretty annoying, but I'm here to bring you, the NEW way to flush dns cache for OS X users!!! Holy crap this is exciting.
So it's as simple as this:
dscacheutil -flushcache
There you have it.
Posted about 1 year back at Simplistic Complexity - Home
As a web dev, you may spend some time messing with DNS and overriding it. Though, it can get annoying when you can't get things back to the way that mere mortals see things on the internet.
lookupd -flushcache was a big tool in my arsenal in Tiger. But Leopard put a rightful end to lookupd, but left us without our known way of flushing the cache.
For the last couple of weeks its been pretty annoying, but I'm here to bring you, the NEW way to flush dns cache for OS X users!!! Holy crap this is exciting.
So it's as simple as this:
dscacheutil -flushcache
There you have it.
Posted about 1 year back at RailsJitsu
We are in the final week of our development phase at work, so I am super busy and don’t have anytime to share new stuff with you.
But the good news is I have been doing a ton of stuff for our gaming platform, and utilizing some cool AJAX stuff that I want to write on sometime next week when things at work chill out a bit. Till then… keep hacking!
Posted about 1 year back at RailsJitsu
We are in the final week of our development phase at work, so I am super busy and don’t have anytime to share new stuff with you.
But the good news is I have been doing a ton of stuff for our gaming platform, and utilizing some cool AJAX stuff that I want to write on sometime next week when things at work chill out a bit. Till then… keep hacking!
Posted about 1 year back at RailsJitsu
We are in the final week of our development phase at work, so I am super busy and don’t have anytime to share new stuff with you.
But the good news is I have been doing a ton of stuff for our gaming platform, and utilizing some cool AJAX stuff that I want to write on sometime next week when things at work chill out a bit. Till then… keep hacking!
Posted about 1 year back at has_many :bugs, :through => :rails - Home
I was able to spend some time on a flight and at home to work on a very annoying performance pit associated with eager loading association’s instantiation code. So, with changeset 8051, hopefully you should see some performance improvement with eagerloading associations with large data sets ( even 100 rows should be good enough to notice the difference – remember, rails does a big fat assed cartesian join when you eager load multiple associations ) – at the cost of a little extra bit of memory. You can catch the mailing list discussion here.
On a very related side note, please take some time to check changeset 8054 as well. As the changeset contains really well written documentation, I wouldn’t reinvent the wheel here. This would make life a lot easier for those of you who are shit scared of sql and use eager loading in some of the worst ways possible because of that.
In any cases, I’d really encourage you to benchmark your code before choosing any solution. If you have never done it before, and you got scared by looking at the generated output, it’s time to try it again. I’d suggest you start with ruby-prof HTML call graphs which are explained very well here
The sample performance script can look as simple as :
1
2
3
4
5
6
7
8
|
require 'ruby-prof'
puts "Sanity check..."
puts Person.find(:all, :include => :items).inspect
results = RubyProf.profile { Person.find(:all, :include => :items) }
File.open "#{RAILS_ROOT}/tmp/profile-graph.html", 'w' do |file|
RubyProf::GraphHtmlPrinter.new(results).print(file)
`open #{file.path}`
end |
And just run the script with script/runner of your rails application. For changeset 8051, you can see my before and after graphs to get a basic idea.
Posted about 1 year back at has_many :bugs, :through => :rails - Home
I was able to spend some time on a flight and at home to work on a very annoying performance pit associated with eager loading association’s instantiation code. So, with changeset 8051, hopefully you should see some performance improvement with eagerloading associations with large data sets ( even 100 rows should be good enough to notice the difference – remember, rails does a big fat assed cartesian join when you eager load multiple associations ) – at the cost of a little extra bit of memory. You can catch the mailing list discussion here.
On a very related side note, please take some time to check changeset 8054 as well. As the changeset contains really well written documentation, I wouldn’t reinvent the wheel here. This would make life a lot easier for those of you who are shit scared of sql and use eager loading in some of the worst ways possible because of that.
In any cases, I’d really encourage you to benchmark your code before choosing any solution. If you have never done it before, and you got scared by looking at the generated output, it’s time to try it again. I’d suggest you start with ruby-prof HTML call graphs which are explained very well here
The sample performance script can look as simple as :
1
2
3
4
5
6
7
8
|
require 'ruby-prof'
puts "Sanity check..."
puts Person.find(:all, :include => :items).inspect
results = RubyProf.profile { Person.find(:all, :include => :items) }
File.open "#{RAILS_ROOT}/tmp/profile-graph.html", 'w' do |file|
RubyProf::GraphHtmlPrinter.new(results).print(file)
`open #{file.path}`
end |
And just run the script with script/runner of your rails application. For changeset 8051, you can see my before and after graphs to get a basic idea.
Posted about 1 year back at has_many :bugs, :through => :rails - Home
I was able to spend some time on a flight and at home to work on a very annoying performance pit associated with eager loading association’s instantiation code. So, with changeset 8051, hopefully you should see some performance improvement with eagerloading associations with large data sets ( even 100 rows should be good enough to notice the difference – remember, rails does a big fat assed cartesian join when you eager load multiple associations ) – at the cost of a little extra bit of memory. You can catch the mailing list discussion here.
On a very related side note, please take some time to check changeset 8054 as well. As the changeset contains really well written documentation, I wouldn’t reinvent the wheel here. This would make life a lot easier for those of you who are shit scared of sql and use eager loading in some of the worst ways possible because of that.
In any cases, I’d really encourage you to benchmark your code before choosing any solution. If you have never done it before, and you got scared by looking at the generated output, it’s time to try it again. I’d suggest you start with ruby-prof HTML call graphs which are explained very well here
The sample performance script can look as simple as :
1
2
3
4
5
6
7
8
|
require 'ruby-prof'
puts "Sanity check..."
puts Person.find(:all, :include => :items).inspect
results = RubyProf.profile { Person.find(:all, :include => :items) }
File.open "#{RAILS_ROOT}/tmp/profile-graph.html", 'w' do |file|
RubyProf::GraphHtmlPrinter.new(results).print(file)
`open #{file.path}`
end |
And just run the script with script/runner of your rails application. For changeset 8051, you can see my before and after graphs to get a basic idea.
Posted about 1 year back at Dr Nic
Recently Wayne Kelly spoke at the Brisbane Ruby and Rails Brigade about Ruby.NET (code repository).
We figured he was some authority figure on the topic, as he wrote it, together with some other members of his QUT department, plus a growing number of Ruby.NET users and contributors.
Local Microsoft officialdom sponsored the show with pizza and then drinks afterwards. Ok, I’m understating that - Charles Sterling is an ex-.NET project manager, who is now in Oz for a Tour of Duty as an Evangelist. In his capacity as an evangelist, he giveth us thy pizza. Twas tasty too.
I believe Ruby.NET is in direct competition with IronRuby for the hearts and minds of Ruby/.NET/Windows developers.
Wayne starts the video below with a comparison of the two, plus a few other Ruby implementations (sorry Evan, Rubinius wasn’t mentioned).
Fortunately we were treated to a demo early in the show. Wayne had recently implemented Ruby code-behind for some of the drag-and-drop widgets that come with Visual Studio. It was very sexy to see all that Ruby being generated.
The video also includes lots of “why Ruby is hard to work with as a compiler writer”, and more importantly, there are lots of audience questions all throughout the talk. This might be why the talk is 1.45hrs long!!
Enjoy… (and the slides from Wayne)
Posted about 1 year back at mir.aculo.us - Home

Coming to Vienna, Austria on November 10 and 11: The EURUKO 07, the 5th European Ruby Conference.
See you there! (It’s cheap, so no excuses accepted if you don’t attend!)
Posted about 1 year back at Riding Rails - home
Paris on Rails is a French-speaking Rails conference that’s taking place in Paris on December 10th. They have a great program for the day with 10 speakers (yours truly included via a video chat). If you speak French, check it out. The one-day event is 100 euro (or 70 euros before November 15th).
Posted about 1 year back at Riding Rails - home
Paris on Rails is a French-speaking Rails conference that’s taking place in Paris on November 15th. They have a great program for the day with 10 speakers (yours truly included via a video chat). If you speak French, check it out. The one-day event is 70 euro.
Posted about 1 year back at Ruby Inside

Thanks to Jan Wedekind for letting me know that the Ruby Association, a formal Ruby promotion group chaired by Matz himself, has chosen a winner in the Ruby Logo Contest. The winning logo is by Tom Schaub and licensed under the Creative Commons Attribution-ShareAlike license.
I'd be really interested to hear what everyone thinks about it in the comments on this post.

Posted about 1 year back at igvita.com
ActiveRecord is arguably one of the best ORM wrappers out there. And as any Rails developer will likely tell you, it's also the backbone of the entire RoR architecture. Having said that, the flexibility comes with a trade off - you have a intermediary that is responsible for constructing the queries, hiding the database logic, converting data types, and the list goes on. All of the steps consume both time and resources, and while find_by_sql is powerful, it is often not enough. Thankfully, while flipping through 'Pro Active Record' by Kevin Marshall, Chad Pytel and Jon Yurek I stumbled across a useful tip: ActiveRecord exposes a collection of methods which allow us to bypass all of its middleman functions and work with the raw SQL connection directly.
Working with low-level CRUD
If you look at the source of ActiveRecord you'll quickly realize that all of its functionality boils down to a few simple methods: connection.insert, connection.update, connection.select_all and connection.delete. Issuing statements through any one of these methods requires a full SQL query - ActiveRecord is no longer responsible for verification. Essentially, we are bypassing everything ActiveRecord brings to the table, short of establishing a communications link to the database.
Bypassing ActiveRecord
Let's establish a standalone connection to a test database and run our CRUD queries:
> ar-raw.rb
require 'active_record'
class DBConn < ActiveRecord::Base
establish_connection(
:adapter => "mysql",
:database => "test",
:username => "user",
:password => "pass",
:host => "localhost"
)
end
# Return all documents; do not convert into ActiveRecord objects, keep as a hashmap
docs = DBConn.connection.select_all("select * from documents")
docs.each do |record|
puts "#{record['id']} :: #{record['title']}"
end
# Insert a document
new_id = DBConn.connection.insert("insert into documents(id, group_id, date_added, title, content) values ('5', '1', '2007-10-26 12:00:00', 'Story title', 'Text')")
puts "\\nNew document id: #{new_id}"
# Update a document
status = DBConn.connection.update("update documents set title = 'New title' where id = 5")
puts "\\nUpdate status: #{status}"
# Check the updated document
p DBConn.connection.select_all("select * from documents where id = 5")
# Delete the update document (returns 0)
status = DBConn.connection.delete("delete from documents where id = 5")
puts "\\nDelete status: #{status}\\n"
# Check the table, once again.
docs = DBConn.connection.select_all("select * from documents")
docs.each do |record|
puts "#{record['id']} :: #{record['title']}"
end
Executing the above code on a sample MySQL database with four document entries produces:
1 :: test one
2 :: test two
3 :: another doc
4 :: doc number four
New document id: 5
Update status: 1
[{"title"=>"New title", "group_id"=>"1", "id"=>"5", "content"=>"Text", "date_added"=>"2007-10-26 12:00:00"}]
Delete status: 1
1 :: test one
2 :: test two
3 :: another doc
4 :: doc number four
Working with low level SQL is definitely a lot more involved, but on the upside, it can also provide significant performance increases. If you are moving lots of data, need access to engine specific functions, or going for straight throughput, it's not something you should overlook. Speed freaks: custom Mongrel handlers with raw ActiveRecord connections!
Posted about 1 year back at igvita.com
ActiveRecord is arguably one of the best ORM wrappers out there. And as any Rails developer will likely tell you, it's also the backbone of the entire RoR architecture. Having said that, the flexibility comes with a trade off - you have a intermediary that is responsible for constructing the queries, hiding the database logic, converting data types, and the list goes on. All of the steps consume both time and resources, and while find_by_sql is powerful, it is often not enough. Thankfully, while flipping through 'Pro Active Record' by Kevin Marshall, Chad Pytel and Jon Yurek I stumbled across a useful tip: ActiveRecord exposes a collection of methods which allow us to bypass all of its middleman functions and work with the raw SQL connection directly.
Working with low-level CRUD
If you look at the source of ActiveRecord you'll quickly realize that all of its functionality boils down to a few simple methods: connection.insert, connection.update, connection.select_all and connection.delete. Issuing statements through any one of these methods requires a full SQL query - ActiveRecord is no longer responsible for verification. Essentially, we are bypassing everything ActiveRecord brings to the table, short of establishing a communications link to the database.
Bypassing ActiveRecord
Let's establish a standalone connection to a test database and run our CRUD queries:
> ar-raw.rb
require 'active_record'
Â
class DBConn < ActiveRecord::Base
establish_connection(
:adapter => "mysql",
:database => "test",
:username => "user",
:password => "pass",
:host => "localhost"
)
end
Â
# Return all documents; do not convert into ActiveRecord objects, keep as a hashmap
docs = DBConn.connection.select_all("select * from documents")
docs.each do |record|
puts "#{record['id']} :: #{record['title']}"
end
Â
# Insert a document
new_id = DBConn.connection.insert("insert into documents(id, group_id, date_added, title, content) values ('5', '1', '2007-10-26 12:00:00', 'Story title', 'Text')")
puts "\\nNew document id: #{new_id}"
Â
# Update a document
status = DBConn.connection.update("update documents set title = 'New title' where id = 5")
puts "\\nUpdate status: #{status}"
Â
# Check the updated document
p DBConn.connection.select_all("select * from documents where id = 5")
Â
# Delete the update document (returns 0)
status = DBConn.connection.delete("delete from documents where id = 5")
puts "\\nDelete status: #{status}\\n"
Â
# Check the table, once again.
docs = DBConn.connection.select_all("select * from documents")
docs.each do |record|
puts "#{record['id']} :: #{record['title']}"
end
Â
Executing the above code on a sample MySQL database with four document entries produces:
1 :: test one
2 :: test two
3 :: another doc
4 :: doc number four
New document id: 5
Update status: 1
[{"title"=>"New title", "group_id"=>"1", "id"=>"5", "content"=>"Text", "date_added"=>"2007-10-26 12:00:00"}]
Delete status: 1
1 :: test one
2 :: test two
3 :: another doc
4 :: doc number four
Working with low level SQL is definitely a lot more involved, but on the upside, it can also provide significant performance increases. If you are moving lots of data, need access to engine specific functions, or going for straight throughput, it's not something you should overlook. Speed freaks: custom Mongrel handlers with raw ActiveRecord connections!
1 ... 475 476 477 478 479 ... 634