The built-in class File provides the facilities for manipulating files in Ruby. Let us explore the basic file operations, including opening, reading, writing along with querying file objects to get information about the file itself.
There are multiple ways to retrive a random row from a table. The fastest way requires no custom SQL.Let's see how to retrieve a random row from a table using ActiveRecord.
Its easy and quite common to forget a database's password. However, this doesn't mean the end of the world. Let's see how we can recover MySQL database server password following five easy steps.
Here is one way to center a fixed-width/fixed-height div at the center of its container. This could be adapted to centering text, images, etc. within their containers. Essentially, we do a bit of arithmetic to get the fixed-sized element centered using absolute positioning and margins. Note that the parent container must have a `position: relative` property for this to work.
Re-initializing a table sequence is quite normal and required in some cases. I had to do that recently. If the table has data and needs to be preserved, then temporarily you have to move the data, delete the data in original table and re-initialize the sequence and copy the original data again. Let's see how to re-initialize table sequence in PostgreSQL.