Skip to content

Instantly share code, notes, and snippets.

View tmaslen's full-sized avatar

Tom Maslen tmaslen

View GitHub Profile
<script>
if ((!document.addEventListener) || (!Array.prototype.indexOf) || (!Array.prototype.forEach) ) {
document.write('<sc' + 'ript src="http://local.bbc.co.uk:1031/news/special/2014/newsspec_7978/content/english/js/lib/vendors/legacy-ie-polyfills.js?v=0.1.0"></sc' + 'ript>');
}
</script>
<div>
<a href="http://local.bbc.co.uk:1031/news/special/2014/newsspec_7978/content/english/frame_1.html?v=0.1.0" id="responsive-iframe-98623215" data-static-iframe-height="600">iFrame</a>
</div>
<div>
@tmaslen
tmaslen / gist:8a9e1f879a0c4a50146c
Created June 10, 2014 18:57
Telegraph interactive loading. If mobile adds a link to open in seperate window, if desktop adds the interactive with an iframe.
// http://www.telegraph.co.uk/sport/football/world-cup/10886068/England-World-Cup-team-selector.html
<script type="text/javascript">
var parentElm = document.getElementsByTagName('script'),
domOutput = document.createElement('div');
parentElm = parentElm[ parentElm.length-2 ];
if(Telegraphics.Modernizr.mobileonmobilesite) {
var lnk=document.createElement('link');
lnk.setAttribute('rel','stylesheet');
lnk.setAttribute('type','text/css');
# window.onerror
Not needed anymore now dev tools are so sophisticated, you can tell the browser to pause on error and then get a full stack trace and a list of all variables in the current scope.
# Don't tell people to do this:
```
var calc = function calc (a, b) { return a * b; }
```
@tmaslen
tmaslen / gist:9409894
Last active July 29, 2021 10:18
IE compatibility and document modes

In BBC News Visual Journalism we have to test 13 different setups of IE.

Test page:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-language" content="<%= translations[vocab_dir].lang %>" />
@tmaslen
tmaslen / gist:8999703
Created February 14, 2014 11:40
ruby lols
env -l
env: illegal option -- l
usage: env [-i] [name=value ...] [utility [argument ...]]
jake:responsive-news maslet02$ man env
jake:responsive-news maslet02$
jake:responsive-news maslet02$ env list
env: list: No such file or directory
jake:responsive-news maslet02$ env help
env: help: No such file or directory
jake:responsive-news maslet02$ env
@tmaslen
tmaslen / gist:8845924
Last active August 29, 2015 13:56
Example of adding a right to left class depending on language
<%
var className = "";
if (["ar", "es"].indexOf(translations[vocab_dir].lang) > -1) {
className = "rtl";
}
%>
<body class="<%= className %>">
...
<?php
class BBC_Indepthtoolkit_Model_Clickableguide
{
public $mainImage = null;
public $hotspots = array();
public $hotspotType = ""; // possible values: thumbnail|shape|label
public $panels = array();
public $layoutType = ""; // possible values: storybody-halfwide-include|SOMETHING ELSE - STEVE TO CONFIRM
public $panelType = ""; // possible values: dyn_full|dyn_half_wide|dyn_full_narrow|dyn_half_narrow|dyn_narrow
@tmaslen
tmaslen / gist:7785915
Created December 4, 2013 11:11
semantic argument around content vs presentational semantics for HTML/CSS
HTML + CSS are not mutually exclusive
Semantic HTML is one of the foundations of modern, professional web development. Semantic HTML is important to us because it increases the machine readability of a website, this is vital for SEO indexing and accessibility (screen readers). But machines read element names and property values, you make HTML more semantic by applying the correct element and by using id and href properties.
Search engine bots and screen readers take no semantic value from classes. Classes are semantic in the fact that they describe to us what they are for, but the primary purpose of them is to serve as hooks for developers to hang JS and CSS onto. Classes are semantically useful for describing how they will be presented, not what the content is about.
The most important thing for class name semantics in non-trivial (i.e. complex) applications is that they be driven by pragmatism and best serve their primary purpose - providing meaningful, flexible and reusable presentational/behavioura
import BBC.AWS.CloudFormation
from BBC.AWS.CloudFormation import SQS, IAM
from BBC.AWS.CloudFormation.Common.ResourcePermissions import SQSActions
try: import json
except ImportError: import simplejson as json
template = BBC.AWS.CloudFormation.Template()
template.description = (