Turn on apache mod_rewrite on Ubuntu
Simply run sudo a2enmod rewrite && sudo invoke-rc.d apache2 restart
Install MySQL with for Apache on Ubuntu
A Guide to install the MySQL module and many others with this simple guide geared towards Ubuntu users:
http://www.howtoforge.com/installing-apache2-with-php5-and-mysql-support-on-ubuntu-9.10-lamp
Correct HTML Entity for Twitter Bootstrap close link
I was recently implementing a Ruby on Rails method that creates flash messages with the beautiful Twitter Bootstrap styled alert message. I did however notice that although the flash messages looked almost correct, the "close" link on the right hand side was no longer correctly styled.
There are no images in the Twitter Bootstrap, so this icon must only be the English letter "x", or so I assumed.
After looking at the CSS comparison from the examples to my code and finding no help, I eventually noticed a slight difference in the "x" character I was using. It turns out that the Twitter Bootstrap is designed to use the HTML entity "×" instead of the keyboard letter "x" which translates incorrectly to entity "x".
Hopefully this can help out anyone else facing a similar confusing issue.
Activating Apache/PHP on Mac alongside Pow server
Instead of rewriting a step-by-step guide on how to do this, I can recommend two great articles that will get you setup in no time.
First read this article on how to setup Apache and PHP on your Mac:
http://superfancy.net/coding/php-mysql-apache-in-mac-osx-leopard/
Next, follow the instructions from 37signals on using Pow alongside Apache. Make sure to pay attention to the troubleshooting section if you had any trouble.
https://github.com/37signals/pow/wiki/Running-Pow-with-Apache
Stub RSpec cookies to set them in your tests
I have recently been in the situation where I was testing a controller that looked up the value of a cookie in a before_filter to validate the user.
I had trouble setting the cookie from within the controller spec so that it was available to the before_filter. The solution that I want to share is
controller.stubs(:cookies).returns({:user_session => 'xxxx'})
The reason I could not get this working earlier was that I was mistakenly trying to stub the cookies method directly. Instead I have to stub the controller cookies, even if it is a private method.
Speed up POW server - Flush the cash
A handy trick to speed up your POW server, if it is running very slowly with a Rails application.
In Terminal run: dscacheutil -flushcache
Detect if page is within Facebook iframe or not: Javascript
There is a handy piece of Javascript which you can use to tell if the current page is within the Facebook canvas iframe, or if it is being viewed normally in the browser.
The Facebook canvas gives its window a special "name" attribute. In most cases unless you generatied the browsing window, it will have no name so we can use the piece of code below.
if(window.name != "") {
//We are on Facebook
}
else
{
//We are just in the normal browser window
}
However, if you changed your window name through Javascript, change the IF statement to match.
With this information, we can hide, add or manipulate our HTML in any way that is required to highlight the difference between the Facebook app and the regular website.
Rails 3 check if the user has specified request.format
The request.format object in Rails is always set. If the user has not specified a value in their URL, e.g. example.com/projects.json, then it will default to :html.
To check if the user has chosen the request format, use this piece of code:
params[:format].nil?
Recent Posts
- Turn on apache mod_rewrite on Ubuntu
- Install MySQL with for Apache on Ubuntu
- Correct HTML Entity for Twitter Bootstrap close link
- Activating Apache/PHP on Mac alongside Pow server
- Stub RSpec cookies to set them in your tests
- Speed up POW server - Flush the cash
- Detect if page is within Facebook iframe or not: Javascript
- Rails 3 check if the user has specified request.format
- Fix Fast Debugger (ruby-debug-ide) on Windows 7
- Fix Rails error: The specified module could not be found: mysql-2.8.1-x86-mingw32 mysql_api.so (LoadError )
- Take Part Training - New website live
- Sort string array values as integer with PHP