No Pressure

Feb 21

How to load a feed with Google Feed API and JQuery

Here is a quick and dirty way to load a xml feed with Google Feed API with Jquery. Enjoy!! :)

First step include the necessary external calls:

<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”</script>

<script type=”text/javascript” src=”https://www.google.com/jsapi”></script>

Second step your javascript function:

<script>

    /*

*  How to load a feed via the Feeds API.

*/

google.load(“feeds”, “1”);

// Our callback function, for when a feed is loaded.

function feedLoaded(result) {

 if (!result.error) {

    // Grab the container we will put the results into

    var container = $(“#latest”);

    $(“#latest”).empty();

    html = “<div><ul>”;

   // Loop through the feeds, putting the titles onto the page.

    // Check out the result object for a list of properties returned in each entry.

   // http://code.google.com/apis/ajaxfeeds/documentation/reference.html#JSON

    for (var i = 0; i < result.feed.entries.length; i++) {

     var entry = result.feed.entries[i];

     html += “<li>” 

          + entry.title 

        + “</li>”;

    }

    html += “</ul></div> “;

    $(“#latest”).append(html);

  }

}

function OnLoad() {

 // Create a feed instance that will grab Digg’s feed.

 var feed = new google.feeds.Feed(“https://gdata.youtube.com/feeds/api/users/devinsupertramp/uploads”);

 // Calling load sends the request off.  It requires a callback function.

 feed.load(feedLoaded);

}

google.setOnLoadCallback(OnLoad);

</script>

Third and last step, add a div into your code to contain the results:

<div id=”latest”></div>

Super quick!! Enjoy!!

Nov 30

Quick and dirty search in Rails

Ever wondered how to quick have a search function in your rails app?

Here is a super quick and maybe a lil dirty way to achieve so.

First step:

The view


 <p><%= form_tag("/searches", :method => "get") do %>

           <%= text_field_tag :keywords, params[:keywords] %> </p>

       <p>  <%= submit_tag("Search") %>

           <% end %>

       </p>

Second step:

search.rb model (app/models)

class Search < ActiveRecord::Base

  def self.find_results(search)

    if search

      Item.find(:all, :conditions => ['name LIKE ?', "%#{search}%"])

    else

      Item.find(:all)

    end

  end

end

Third step:

searches_controller.rb (app/controllers)

class SearchesController < ApplicationController

  def index

    @results = Search.find_results(params[:keywords])

  end

end

Fourth step:

index.html.erb (app/views/searches)

<% @results.each do |result| %>

             <p><%= result.name %></p>

Done :)

Just don’t forget to add   resources :searches, :controllers => ‘searches’ to your routes.rb!

Oct 17

Ruby headaches pills

If:

script/rails generate controller Hello

Is failing, try to remember that you have probably installed more than one version of rails in your history, so you might need to call:

rvm use 1.9.1 —default :)

Sep 15

“The future is distributed!”

Sep 14

[video]

Sep 06

ckck:

Control panel at IBM. San Jose, California, circa 1958.
Photograph by Arnold Del Carlo.

ckck:

Control panel at IBM. San Jose, California, circa 1958.

Photograph by Arnold Del Carlo.

Home abroad -

I still treasure my memories of two weeks spent in Buenos Aires almost 3 years ago, and this article has brought all of them back again :)

Sep 05

“Work smarter, play harder” — Never got why we have to work hard… ;)

Sep 02

“Schmidt says definitively: the next generation of leaders and startups to emerge will involve mobile, local, and social. He explains that we’ve exhausted the limits of the PC as a platform, the future will be mobile first.” — Reinvent the future, everything else will follow.

(Source: TechCrunch)

Aug 27

Dublin sunset

Dublin sunset