Skip to content

Instantly share code, notes, and snippets.

This is the first paragraph.1

  • List item one.2
  • List item two.3

Footnotes

  1. This is the first note.

  2. This is the second note.

  3. This is the third note, defined out of order.

@samwilson
samwilson / content_script.js
Created December 12, 2019 23:23
ResourceLoader queue weirdness
console.log( 'Start of content_script.js' );
const script = document.createElement( 'script' ),
body = document.getElementsByTagName( 'body' )[ 0 ];
script.src = browser.extension.getURL( 'injected_script.js' );
body.appendChild( script );
console.log( 'End of content_script.js' );
@samwilson
samwilson / website.html
Last active January 28, 2016 09:29 — forked from auneri/website.html
Another more-better motherfucking website template.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
h1, h2, h3 {
line-height: 1.2;
}
body {
@samwilson
samwilson / people.opml
Last active August 29, 2015 14:13
Planet Freo OPML
<?xml version="1.0"?>
<opml version="1.1">
<head>
<title>Planet Freo</title>
<dateCreated>2015-01-14T00:48:45-08:00</dateCreated>
<dateModified>2015-01-14T00:48:45-08:00</dateModified>
</head>
<body>
<outline text="Freo Tribe" htmlUrl="http://fremantlesociety.org.au/blog" xmlUrl="http://fremantlesociety.org.au/blog/feed/atom/" isDown=""/>
<outline text="City of Fremantle Mayor Brad Pettitt's Blog" htmlUrl="http://cofremantle.wordpress.com" xmlUrl="http://cofremantle.wordpress.com/feed/atom/" isDown=""/>
@samwilson
samwilson / nositepath.js
Last active August 29, 2015 14:13
"No site_path" module for DrupalGap. Now located at https://github.com/samwilson/nositepath
nositepath_temp_path = 'http://example.org';
if (!Drupal.settings.site_path || Drupal.settings.site_path == '') {
Drupal.settings.site_path = variable_get('nositepath_site_path', nositepath_temp_path);
}
/**
* Implements hook_deviceready().
*/
function nositepath_deviceready() {
@samwilson
samwilson / form-saving-prompt.js
Created November 8, 2012 06:36
Prompt when leaving unsaved POST forms
$("form[method='post'] :input").change(function() {
window.onbeforeunload = function(){
return true; // Prompt if any input has changed
};
});
$("form[method='post']").submit(function() {
window.onbeforeunload = null; // Only remove the prompt if it's the submit button
});
@samwilson
samwilson / README.md
Created July 19, 2011 03:41
Javascript conversion of datetime strings in PHP pages to user's timezone
@samwilson
samwilson / tabular-forms.js
Created July 18, 2011 04:06
Preventing duplicate rows in a tabular HTML form
$().ready(function() {
// Save the current value of a select when it gains focus, to
// be used in case the value is changed.
$("table select").live('focus', function(){
$(this).data('oldVal',$(this).val());
});
//After changing a value in any row,
$("table select").live('change',function() {
@samwilson
samwilson / text.php
Created May 5, 2010 09:53
Smart Titlecase function (incomplete)
<?php defined('SYSPATH') or die('No direct script access.');
/**
*
*/
class Text extends Kohana_Text
{
/**
*
* Apply the titlecase filter to a string: removing underscores, uppercasing