Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am rayboyd on github.
  • I am rayboyd (https://keybase.io/rayboyd) on keybase.
  • I have a public key ASBokciSsbWPh0ZBq6c8zfUrNhRq4wwBqkcLRiqwwFMZPQo

To claim this, I am signing this object:

@rayboyd
rayboyd / view.js
Created May 6, 2012 14:18
Viewport dimensions
(function(document) {
var el = (document.compatMode === "CSS1Compat")
? document.documentElement
: document.body;
return {
'height': el.clientHeight,
'width': el.clientWidth
}
}(document);
@rayboyd
rayboyd / imdb.js
Created July 19, 2011 23:25
Bookmarklet to send basic IMDb info via GET request to a url.
javascript:(function(){var meta=document.getElementsByTagName('meta');for(var i=0;i<meta.length;i++){switch(meta[i].getAttribute('property')){case'og:title':var title=encodeURIComponent(meta[i].getAttribute('content'));break;case'og:director':var director=encodeURIComponent(meta[i].getAttribute('content'));break;case'og:url':var url=encodeURIComponent(meta[i].getAttribute('content'));break;};};window.open('http://url.co.uk/?title='+title+'&director='+director+'&url='+url);})();
$(document).ready(function() {
// html5 feature support
for (var k in html5)
console.log(k, '...', html5[k]);
});
(function(window, document, navigator, undefined) {
var html5 = {
appcache: !!window.applicationCache,
geolocate: !!navigator.geolocation,

HTML5 and friends.

A bigass bulleted list of features.

I commonly need to get a big list of all the stuff people think of when they think new and shiny these days. This list is for that.

I take a very inclusionist approach to it. 1

javascript APIs

  • Web Storage (localStorage, sessionStorage)
  • Web SQL Database
@rayboyd
rayboyd / html5.js
Created January 30, 2011 00:22
Rudimentary HTML5 feature support testing.
for (var k in html5)
console.log(k, '...', html5[k]);
(function(window, document, navigator, undefined) {
var html5 = {
appcache: !!(window.applicationCache),
audio: !!(document.createElement('audio').canPlayType),
dragdrop: !!('draggable' in document.createElement('span')),
fileapi: !!(typeof FileReader !== 'undefined'),
geolocate: !!(navigator.geolocation),
int sendrecv(libre rdb, char *sendbuf)
{
int s, r;
char recvbuf[LIBRE_MAX_BUFSIZE];
/* send data */
s = send(rdb->fd, sendbuf, strlen(sendbuf), 0);
if (s < 0) return LIBRE_FAILURE;
free(sendbuf);
var agent = {
perpage: '15',
since_id: '0',
query: null,
page: null,
completed_in: null,
next_page: null,
refresh_url: null,
results: {
cache: []
int sendrecv(redis rdbs, const char *fmt, ...)
{
va_list ap;
char *buf;
char *tmpbuf;
size_t bufsize = 0;
int arglen = 0;
for (;;) {
#! /bin/sh
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $syslog
# Required-Stop: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db