Skip to content

Instantly share code, notes, and snippets.

View voxpelli's full-sized avatar

Pelle Wessman voxpelli

View GitHub Profile
@voxpelli
voxpelli / gist:659572
Created November 2, 2010 12:57 — forked from remy/gist:330318
/**
* Add this script to the end of your document that use <input autofocus type="text" />
* or <input type="text" placeholder="username" /> and it'll plug support for browser
* without these attributes
* Minified version at the bottom
*/
// By remy, from http://gist.github.com/330318
(function () {
function each(list, fn) {
@voxpelli
voxpelli / host-meta.json
Created November 21, 2010 17:23
Quick sketch of a possible future for OEmbed

OEmbed 2.0?

Quick sketch of a possible future for OEmbed based on Host-meta, Web Linking and some Dublin Core. Just a sketch yet – eg. unsure about to what extent it would be good to use Dublin Core.

Also not at all discussed within the community.

An alternative future would be to just pick the discovery part from this and keep the data format as it is now.

Reference URLs

@voxpelli
voxpelli / host-meta.json
Created November 21, 2010 17:47
Sketch of a possible oEmbed 1.1 autodiscovery mechanism

OEmbed Autodiscovery?

A quick sketch at a possible updated autodiscovery mechanism for oEmbed.

By adding a new link relation, “http://oembed.com/spec/1.1/prop/embed”, that defines an the link to an oEmbed representation of a resource and combining that with the template property of the XRD specifications link tag we get a way to specify an oEmbed endpoint.

Add to that a new property type, http://oembed.com/spec/1.1/prop/scheme, that defines the scheme of such a link and we can make those discoverable as well. Supporting http://oembed.com/spec/1.1/prop/scheme might be optional since all it does is enable consumers to precheck whether an endpoint provides embeds for a class of URI:s or not.

Possibly also add a new property, http://oembed.com/spec/1.1/prop/type, to define which types are to be expected from the endpoint. This would make it possible for eg. those looking for only photos to exclude all oEmbed providers that doesn’t provide photo embeds.

<?php
$provider = new stdClass;
$provider->disabled = FALSE; /* Edit this to true to make a default provider disabled initially */
$provider->name = 'digg';
$provider->title = 'Digg';
$provider->url = 'http://services.digg.com/1.0/endpoint';
$provider->consumer_advanced = array(
'signature method' => 'HMAC-SHA1',
'authentication realm' => 'http://services.digg.com/',
'request token endpoint' => '?method=oauth.getRequestToken',
<?php
function themename_vocabulary_links($vid, $node, $invert = FALSE) {
// Clone the node since we don't want remove terms on the $node object.
$node_copy = clone $node;
foreach($node_copy->taxonomy as $tid => $term) {
if (($term->vid != $vid && !$invert) || ($term->vid == $vid && $invert)) {
// Remove terms not of the specified vid.
unset($node_copy->taxonomy[$tid]);
}
@voxpelli
voxpelli / gist:987000
Created May 23, 2011 16:31
A simple way of getting the content of XML request bodies
<?php
// If the XML is sent as the body
if ((!empty($_SERVER['HTTP_CONTENT_TYPE']) && strtolower($_SERVER['HTTP_CONTENT_TYPE']) === 'application/xml')) {
$xml = file_get_contents('php://input');
}
// If the XML is sent as a POST-parameter
if (isset($_POST['xml'])) {
$xml = $_POST['xml'];
@voxpelli
voxpelli / catch-all-argument.php
Created June 9, 2011 21:17
Random JSON object and arg-definition
<?php
// For use with above JSON-objects
array(
'args' => array(
array(
'name' => 'foo',
'optional' => FALSE,
'source' => 'data',
'description' => 'An array of key/values - for every key a news item will be posted with the key as title and the value as body',
'type' => 'array',
// ==UserScript==
// @name OtherMes
// @namespace http://kodfabrik.se/othermes/
// @description Finds other social profiles of the current profile and shows them in the page.
// @include https://twitter.com/*
// @include http://twitter.com/*
// ==/UserScript==
(function () {
var cache = {}, findProfiles, fetchProfile, fetchScreenName, insertProfile, stopIt, newTweets = false, favicons = {
@voxpelli
voxpelli / vptest.info
Created July 5, 2011 20:01
OAuth.module 3.x example - a test I made to verify the D7 port of the module - should work well on D6 as well though
name = VoxPelli OAuth Test
core = 7.x
dependencies[] = oauth_common
dependencies[] = http_client
/*! hsv_to_hsl.scss | MIT License | https://gist.github.com/voxpelli/1069204 */
@function max($v1, $v2) {
@return if($v1 > $v2, $v1, $v2);
}
@function min($v1, $v2) {
@return if($v1 < $v2, $v1, $v2);
}
@function hsv_to_hsl($h, $s: 0, $v: 0) {