Wednesday, October 15, 2008

Sorting records based on the exact order of passed parameters to finder

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/dde7efa8f8f455e5/e4090afeb6c27608?lnk=gst&q=loveajax#e4090afeb6c27608

In Ruby:
order = [5,2,3]
Project.find(:all, :conditions => ["id IN (?)", order], :order =>
"field(id, #{order.join(",")})")

In MySQL:
SELECT * FROM projects WHERE (projects.`id` IN (1,2,3,5,7,6)) ORDER BY field(id, 5,1,2,3,7,6);

Wednesday, September 17, 2008

Basic Authentication using Apache and mod_rails

http://code.google.com/p/phusion-passenger/issues/detail?id=94&can=1&q=allow&colspec=ID%20Type%20Status%20Priority%20Milestone%20Stars%20Summary

Copy pasted from the above link:
What steps will reproduce the problem?
1. Add a password file with htpasswd
2.
ServerName caswell-box
DocumentRoot /home/user/app/public

Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
AuthName "Enter password"
AuthUserFile /etc/apache2/passfile.passwd
AuthType Basic
Require valid-user



3. Attempt to access the app in your web browser, and either enter the
wrong user/pass or hit cancel.

What is the expected output? What do you see instead?

The expected output is an authentication rejection, instead while the
static assets handled by Apache are restricted, the rails app is run by
passenger and generates pages without CSS/images.

What version of the product are you using? On what operating system?

Ubuntu 8.04, Passenger 1.9.1 RC2

Please provide any additional information below.

Looks like Passenger does not inherit the permissions from apache.

Monday, September 15, 2008

Find out mysql socket

  1. Enter mysql command line with 'mysql -u root -p'
  2. mysql> mysql status

Thursday, September 11, 2008

Duplicating a table in MySQL

CREATE TABLE duplicate_name SELECT * FROM original_table;

Thursday, August 28, 2008

GIT - Ignore uncommitted changes in already tracked files

in order to ignore uncommitted changes in already tracked files, please refer to the git update-index --assume-unchanged documentation

http://www.kernel.org/pub/software/scm/git/docs/git-update-index.html

Thursday, July 31, 2008

TextMate discoveries

Option+Apple+o = Overwrite mode

Thursday, July 17, 2008