Skip to content

Instantly share code, notes, and snippets.

View PaulKinlan's full-sized avatar

Paul Kinlan PaulKinlan

View GitHub Profile
@PaulKinlan
PaulKinlan / dataUriForStylesheet.js
Created March 8, 2011 01:11
Add dataURI styleshhet
var toDataURI = function(datatype, data) {
return "data:" + datatype +";base64," + window.btoa(data);
};
var renderStyleSheet = function() {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = toDataUri("text/css", "body { background-color: red;}" );
document.head.appendChild(link);
};
@PaulKinlan
PaulKinlan / gist:1222849
Created September 16, 2011 19:05 — forked from ianb/gist:1222633
Web Intent use case brainstorm

Use Cases

Screen scrape microdata:

  • grab an ical event (send)
  • grab an hcard
  • atom feed
  • make note of an hreview (actually I can't think of what you'd do with an hreview)
  • ? generic grabbing, or we specifically figure out support for particular kinds of data (i.e., microformats.org specs)
@PaulKinlan
PaulKinlan / subscribe.html
Created October 12, 2011 13:22
Subscribe Intent
<!doctype html>
<html>
<head>
<intent action="http://webintents.org/subscribe" type="application/atom+xml" />
<script src="http://webintents.org/webintents.min.js"></script>
</head>
<body>
<button id="go">Go</button>
</body>
<intent
action="http://webintents.org/edit"
type="image/*"
href="edit.html"
/>
var i = new Intent({
"action": "http://webintents.org/save",
"type": "image/*",
"data": blob
})
var onsuccess = function(data) {
var img1 = document.getElementById("img1");
img1.src = URL.createObjectURL(data);
};
window.addEventListener("load", function() {
if(window.intent && window.intent.action === "http://webintents.org/save") {
var data = window.intent.data;
if(data instanceof Blob) {
// do something with the blob.
}
else {
// do something with the object.
var i = new Intent({
"action": "http://webintents.org/save",
"type": "image/*",
"extras": { "url": "http://placekitten.com/g/200/300" }
})
var onsuccess = function(data) {
var img1 = document.getElementById("img1");
if(data instanceof Blob) {
img1.src = URL.createObjectURL(data);
var i = new Intent({
"action": "http://webintents.org/save",
"type": "text/uri-list",
"data": "http://placekitten.com/g/200/300"
})
var onsuccess = function(data) {
};
var onerror = function(){ };
@PaulKinlan
PaulKinlan / dabblet.css
Created July 19, 2012 01:28
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height: 100%;
@PaulKinlan
PaulKinlan / gist:4160675
Created November 28, 2012 11:46
Encapsulating Request Animation Frame
/*
Javascript is a funny thing.
Here are two things that will hit you with requestAnimationFrame
1) If you alias the window.requestAnimationFrame function on to anything other
than a window object, you get an Illegal Invocation Error.
You can solve this by using call() with the window object set.