#Stay Standalone
A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> | |
<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/underscore.js/1.1.4/underscore-min.js"></script> | |
</head> | |
<body> | |
<p id="loading_msg">Loading...</p> | |
<script type="text/javascript"> | |
/* To being with, just in case the "$" is already taken in the global scope |
/*jslint undef: true, nomen: true, eqeqeq: true, plusplus: true, newcap: true, immed: true, browser: true, devel: true, passfail: false */ | |
/*global window: false, readConvertLinksToFootnotes: false, readStyle: false, readSize: false, readMargin: false, Typekit: false, ActiveXObject: false */ | |
var dbg = (typeof console !== 'undefined') ? function(s) { | |
console.log("Readability: " + s); | |
} : function() {}; | |
/* | |
* Readability. An Arc90 Lab Experiment. | |
* Website: http://lab.arc90.com/experiments/readability |
// This is the library that'll handle all of our input tracking and job dispatching | |
var nodeio = require('node.io'); | |
// The base_url is the site you want to crawl. | |
// Links is an array of all the links seen as <a> tags, but not yet scraped. | |
// crawled_links is the array of all the pages already scraped. | |
var base_url = 'http://reddit.com', | |
links = [base_url], | |
crawled_links = []; |
#Stay Standalone
A short script to prevent internal links to a "webapp" added to iPhone home screen to open in Safari instead of navigating internally.
/* | |
* Copyright (C) 2011 Yehonatan Daniv <[email protected]> | |
* | |
* DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
* TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
* | |
* 0. You just DO WHAT THE FUCK YOU WANT TO. | |
* | |
* supr.js is a simple wrapper for the Object.create mechanism of ES5, | |
* to ease the creation of objects via the Create function. |
By default, Rails applications build URLs based on the primary key -- the id
column from the database. Imagine we have a Person
model and associated controller. We have a person record for Bob Martin
that has id
number 6
. The URL for his show page would be:
/people/6
But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6
here, is called the "slug". Let's look at a few ways to implement better slugs.
<!DOCTYPE html> | |
<!-- | |
This is a simple experiment relying on ECMAScript 6 Proxies. To try this out, | |
use Aurora (http://www.mozilla.org/en-US/firefox/channel/). | |
The goal was to create a HTML writer where the method names were really just | |
the HTML tags names, but without manually creating each method. This uses | |
a Proxy to create a shell to an underlying writer object that checks each | |
method name to see if it's in a list of known tags. |
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () { | |
var Storage = function (type) { | |
function createCookie(name, value, days) { | |
var date, expires; | |
if (days) { | |
date = new Date(); | |
date.setTime(date.getTime()+(days*24*60*60*1000)); | |
expires = "; expires="+date.toGMTString(); |
// Simulated static super references (as proposed by the current draft of the ECMAScript 6 specification) | |
//------------------ Library | |
function inherits(subC, superC) { | |
var subProto = Object.create(superC.prototype); | |
// At the very least, we keep the "constructor" property | |
// At most, we preserve additions that have already been made | |
copyOwnFrom(subProto, subC.prototype); | |
setUpHomeObjects(subProto); |