mysql formatted select results
To get formatted results for select statements use \G as a suffix for the query.
select * from table_name\G
Related cards:
detect and select method in ruby
detect method in ruby returns the first item in the collection for which the block returns TRUE and returns nil if it doesn't find any. It has an optional argument containing a proc that calculates a “default” value — that is, the value to return ...
Clearing out old Rails session records from a MySQL database
To delete sessions based on a hard coded cut-off date:
DELETE FROM sessions WHERE updated_at < STR_TO_DATE('23.05.2013',GET_FORMAT(DATE,'EUR'));
Replacing cut-off date with period of inactivity
DELETE FROM sessions WHERE updated_at ...
Retrieve SQL query in Rails 2.x
The method is construct_finder_sql(options) (lib/active_record/base.rb:1681) you will have to use send because it is private.
sql = Item.send :construct_finder_sql, :select => :all, :include => [:categories, :prices], :conditions => cond...
know which window manager is running
In ubuntu, you have a variety of window managers to choose from. Though Ubuntu 12.04 comes with Unity as the default you can switch back to Gnome, or choose other managers like Cinnamon.
If you want to know, which window manager you are running c...
difference between attr_accessor and initialize
attr_accessor is used to create setter and getter methods for instance variables so that they can be accessed outside the class. initialize is the special method in ruby that gets called when an object is instantiated.
class Birthday
attr_ac...