Skip to content

Instantly share code, notes, and snippets.

View jcleblanc's full-sized avatar

Jonathan LeBlanc jcleblanc

View GitHub Profile
USE 'http://www.jonleblanc.com/projects/yql/weather_locations.xml' AS weather_location; select * from weather.forecast where location in (SELECT loc.id FROM weather_location WHERE location='London' LIMIT 1);
<canvas id="test_canvas" width="400" height="400">
If the canvas element is not supported in your browser, this text will be displayed
</canvas>
var example = document.getElementById('test_canvas');
var context = example.getContext('2d');
context.fillStyle = "rgb(255,0,0)";
context.fillRect(30, 30, 50, 50);
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="10" yahoo:created="2010-03-31T06:27:19Z" yahoo:lang="en-US" yahoo:updated="2010-03-31T06:27:19Z" yahoo:uri="http://query.yahooapis.com/v1/yql?q=select+*+from+flickr.photos.search+where+has_geo%3D%22true%22+and+text%3D%22san+francisco%22">
<diagnostics>
<publiclyCallable>true</publiclyCallable>
<url execution-time="444"><![CDATA[http://api.flickr.com/services/rest/?method=flickr.photos.search&has_geo=true&text=san%20francisco&page=1&per_page=10]]></url>
<user-time>445</user-time>
<service-time>444</service-time>
<build-version>5275</build-version>
</diagnostics>
<results>
<?php
$yql_url = 'http://query.yahooapis.com/v1/public/yql?';
$query = 'SELECT * FROM flickr.photos.search WHERE has_geo="true" AND text="san francisco"';
$query_url = $yql_url . 'q=' . urlencode($query) . '&format=xml';
$photos = simplexml_load_file($query_url);
$result = build_photos($photos->results->photo);
echo $result;
function build_photos($photos){
<results>
<item>
<title>Browser MVC with YQL and YUI</title>
<link>http://www.slideshare.net/jcleblanc/browser-mvc-with-yql-and-yui</link>
<description><![CDATA[<img src="http://cdn.slidesharecdn.com/confoobrowsermvc03122010-100312101651-phpapp02-thumbnail-2?1268510282" alt ="" style="border:1px solid #C3E6D8;float:right;" /><br> YQL is a highly rich and dynamic utility for capturing data from any place on the web. When we couple this functionality with YUI we have wonderful functionality for designing apps and sites easily and that scale around MVC design patterns.]]></description>
<content:encoded xmlns:content="http://purl.org/rss/1.0/modules/content/"><![CDATA[<img src="http://cdn.slidesharecdn.com/confoobrowsermvc03122010-100312101651-phpapp02-thumbnail-2?1268510282" alt ="" style="border:1px solid #C3E6D8;float:right;" /><br> YQL is a highly rich and dynamic utility for capturing data from any place on the web. When we couple this functionality with YUI we have wond
<script type='text/javascript' src='yql_js_widget.js'></script>
<div id='widgetContainer'></div>
<script type='text/javascript'>
var config = {"debug":true};
var format = "<br style='clear:both' /><img src='{content}' width='620' height='500' alt='map' />";
var yqlQuery = "SELECT * FROM maps.map WHERE (latitude, longitude) IN (SELECT match.place.centroid.latitude, match.place.centroid.longitude FROM geo.placemaker WHERE documentURL = 'http://www.cnn.com/' AND documentType='text/html' AND appid='')";
var insertEl = "widgetContainer";
return {
//push widget on the load stack
push: function(query, config, format, insertEl){
//validate widget variables
if (query == null || format == null || insertEl == null){
if (setupConfig["debug"] && window.console){ console.log("Missing query, return format or insert element"); }
return null;
}
//variable instantiation
var yqlPublicQueryURL = "http://query.yahooapis.com/v1/public/yql?";
var widgetStack = [];
var currString, resultFormat, queryInsert, setupConfig = [];
var regex = /\{([\w\-\.\[\]]+)\}/gi;
/****************************************************
* Method: Get YQL Data
* Description: Use the query provided to make a
* request to YQL endpoint to capture data
*****************************************************/
var getYQLData = function(query){
//prepare the URL for public YQL queries:
var sURL = yqlPublicQueryURL + "q=" + encodeURI(query) + "&format=json&callback=yqlWidget.getYQLDataCallback";
//add any environment files specified in the config