Skip to content

Instantly share code, notes, and snippets.

View tiff's full-sized avatar

Christopher Blum tiff

View GitHub Profile
/**
* "Happy Birthday Nenad" OpenSocial Script
* UNTESTED
* Probably won't work in most OpenSocial containers
* due to privacy settings
*/
var NENADS_USER_ID = '<UserId>'; // eg. VIEWER
var req = opensocial.newDataRequest();
/**
* Example:
* convertToPrettyDate("Sat, 23 Jan 2010 18:45:42 +0100") // => "7 hours ago"
*/
var convertToPrettyDate = (function() {
var JUST_NOW = "Just now",
MINUTES_AGO = "{t} minute{s} ago",
HOURS_AGO = "{t} hour{s} ago",
YESTERDAY = "Yesterday",
DAYS_AGO = "{t} day{s} ago",
/**
* toLolcatString()
* Converts a string from plain english to lolcat speak using YQL and jQuery
*
* @example
* toLolcatString("Hi. How are you?", function(lolcatStr) { alert(lolcatStr); }); // => "OH HAI. HOWZ U?"
*/
var toLolcatString = (function() {
var YQL_QUERY = "SELECT content FROM html WHERE url=\"http://speaklolcat.com/?from={str}\" AND xpath='//textarea[@id=\"to\"]'";
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="os:Name Tag">
<Require feature="opensocial-data"/>
<Require feature="opensocial-templates"/>
</ModulePrefs>
<Content type="html"><![CDATA[
<script xmlns:os="http://ns.opensocial.org/2008/markup" type="text/os-data">
<os:PeopleRequest key="Owner" userId="@owner" groupId="@self"/>
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Message Bundle Substitution in Remote Requests">
<Require feature="opensocial-0.9" />
<Require feature="opensocial-templates" />
<Require feature="opensocial-data" />
<Locale lang="all">
<msg name="foo">Hello World</msg>
</Locale>
</ModulePrefs>
<div>Message (remotely loaded): __MSG_foo__</div>
var sys = require('sys'),
http = require('http'),
urlModule = require('url'),
querystring = require('querystring');
http.createServer(function(req, res) {
var urlObj = urlModule.parse(req.url),
params = querystring.parse(urlObj.query),
url = params.url,
dest = 'images/' + new Date().getTime() + '.png';
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<!--
FIG - Feature Inspector Gadget, find out what gadget features are supported by any gadget container.
Copyright (C) 2009 XING AG
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Timestamp of last visit">
<Require feature="setprefs" />
</ModulePrefs>
<Content type="html"><![CDATA[
<script>
var prefs = new gadgets.Prefs();
document.write("Timestamp of last visit: " + prefs.getInt("timestamp_canvas"));
prefs.set("timestamp_canvas", new Date().getTime());
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="Test OpenSocial Templates" />
<Content type="html"><![CDATA[
<script type="text/javascript" src="http://ostemplates-demo.appspot.com/ostemplates.js"></script>
<!-- A simple inline template -->
<script type="text/os-template">
<div style="font-size: 20px">Hello world!</div>
</script>