Detect if page is within Facebook iframe or not: Javascript




  if( != "") {
    //We are on Facebook
    //We are just in the normal browser window




Update Feb 2016:


if('iframe_canvas_fb') > -1)

Rails 3 check if the user has specified request.format















Find the line (around 79):

Debugger::PROG_SCRIPT = ARGV.shift

Replace it with:

script = ARGV.shift
puts Debugger::PROG_SCRIPT
#Debugger::PROG_SCRIPT = ARGV.shift






This occurs every time I try to load the Webrick server.


The location of these folders on Windows 7 is:


Sort string array values as integer with PHP


However, you may have the following array:

$scores = array(




usort($scores, SORT_NUMERIC);
//0 = 28-Joe
//1 = 32-Andy
//2 = 43-Steve

Detect if HTML 5 Geolocation is Enabled

If you want to check whether a browser has HTML 5 geolocation support enabled and display a warning message to the user if it is not, then this function should help you out.

function display_nosupport_message()
		$('#map_canvasâ€™).text('Your browser does not support HTML 5 geolocation. ');

In this example I check to see if the navigator.geolocation method is available. If not then I use a jQuery command to update the div that would normally house the Google Map by adding warning text for the user.

Easy Javascript crossfading with jQuery

In todayâ€™s World Wide Web many websites are featuring projects or artwork on their homepage via a crossfading gallery. In the past this was normally done by an Adobe Flash movie but these days it is usually much easier to implement with Javascript.

A Javascript solution provides many benefits such as cross browser support, no plugins required and highly improved performance. There are many different ways to implement a crossfade in Javascript, many of them very complex, so today I will be showing you how this effect can be achieved with the jQuery framework, Cycle plugin and only a few lines of code.

First of all you must include the jQuery JavaScript by either downloading it from jQuery or including it right from their website.

Next we must download the Cycle plugin and include it from your computer.

Next step is to define your slideshow files in HTML. Simply write your img tags into a slideshow div tag.

Finally all you have to do is include an inline Javascript function to initiate the cycler. Remember to match up the class name of the slideshow div with the class name in the function.

<script type="text/javascript">
$(document).ready(function() {

That's it, a Javascript crossfading gallery in minutes. To see examples and additional effects that the cycle plugin can perform, please see the cycle plugin website.

Unescape HTML output in Rails 3 using html_safe

I've been having the problem of trying to output generated HTML into a ruby view template in a similar fashion to this:

 <%= generated_html %>

The problem is in Rails 3 you no longer need the "h" function which escapes HTML. This is now done automatically.

The solution is to tell rails that this is safe HTML and you want to unescape the output using the "html_safe" function as follows:

 <%= generated_html.html_safe %>

Fix NetBeans "db:migrate" task does not exist

I have recently reinstalled Ruby on Rails 3.0.0 and created a new Rails project in NetBeans 9.6.1

I could not migrate my database, or any other rake tasks for that matter. I kept getting the error: "db:migrate" task does not exist

The solution is to right click your project select "Run/Debug Rake Task" and then click the button titled "Refresh Tasks".

Once this is done you should see a list of all your rake tasks. After this you can simply re-run the db:migrate task and it will work.

© Blake Simpson, 2012 – 2018