Ruby on Rails 3 Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ on OSX – Stack Overflow

This error also shows up after upgrading Ubuntu versions. A quick fix was to uninstall and reinstall the mysql gem. Also ensure your database.yml file has proper connection credentials.


$> gem uninstall mysql2

Assuming mysql2 is in your Gemfile

$> bundle install

Ruby on Rails 3 Can't connect to local MySQL server through socket '/tmp/mysql.sock' on OSX – Stack Overflow.

Dieter Rams Reflects on His 10 Principles of Good Design – Kasia Cieplak-Mayr von Baldegg – The Atlantic

The 10 principles of good design according to Dieter Rams

  1. Good design is innovative
  2. Good design makes a product useful
  3. Good design is aesthetic
  4. Good design makes a product understandable
  5. Good design is unobtrusive
  6. Good design is honest
  7. Good design is long lasting
  8. Good design is thorough down to the last detail
  9. Good design is environmentally friendly
  10. Good design is as little design as possible

 

Dieter Rams Reflects on His Principles of Good Design – Kasia Cieplak-Mayr von Baldegg – The Atlantic.

Easily Generate Random Numbers with Javascript

Sometimes you need a random number from javascript. In this case I needed to get a random integer to select a CSS class referencing a header image from an array to randomly show a header graphic.

Here’s the snippet:

Math.random() generates a “floating-point, pseudo-random number” in the range of 0 and 1. For example:

 

To get an integer for use as an array index another javascript method is required: Math.floor()

For example – to generate a random integer between 0 and 6:

Or put it all in a function for easy re-use and to get a random number of any size:


// Returns a random integer between min and max
// Using Math.round() will give you a non-uniform distribution!
function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}

Reference:
Math.random – JavaScript | MDN.