Skip to content

Instantly share code, notes, and snippets.

View markhowellsmead's full-sized avatar

Mark Howells-Mead markhowellsmead

View GitHub Profile
@markhowellsmead
markhowellsmead / jsload.js
Created May 15, 2014 10:57
Load Javascript files to a page in sequence if Javascript is available
<script>
!function(e,t,r){function n(){for(;d[0]&&"loaded"==d[0][f];)c=d.shift(),c[o]=!i.parentNode.insertBefore(c,i)}for(var s,a,c,d=[],i=e.scripts[0],o="onreadystatechange",f="readyState";s=r.shift();)a=e.createElement(t),"async"in i?(a.async=!1,e.head.appendChild(a)):i[f]?(d.push(a),a[o]=n):e.write("<"+t+' src="'+s+'" defer></'+t+">"),a.src=s}(document,"script",[
"//code.jquery.com/jquery-latest.js",
"js/ui.js"
]);
</script>
@markhowellsmead
markhowellsmead / js_appload.js
Last active August 29, 2015 14:01
Load advanced Javascript if the browser understands modern terms{}
/*
From http://responsivenews.co.uk/post/18948466399/cutting-the-mustard :
As the application loads we earmark incapable browsers with the above code and exclude the bulk of the Javascript powered UI from them, leaving them with clean, concise, core experience.
Here’s the justification for each condition:-
document.querySelector - A large part of any JS library is its DOM selector. If the browser has native CSS selecting then it removes the need for a DOM selector. QuerySelector has been available in Firefox since 3.5 at least and has been working in webkit for ages. It also works in IE9.
window.localStorage - Although we are not using it yet, we are planning on making considerable use of it. Imagine that if you first came to the mobile site we downloaded all the stories straight away and stored them in localStorage. They’d then be available to use while you are going through an areas of sketchy bandwidth.
@markhowellsmead
markhowellsmead / extbase-plugin.ts
Last active August 29, 2015 14:01
Include a TYPO3 ExtBase plugin via TypoScript using AddThis extension as an example
# Include a TYPO3 ExtBase plugin via TypoScript using AddThis extension as an example
# www.mhm.li | m@mhm.li | 5/2014 | Free use, no credit required
lib.share = USER
lib.share {
userFunc = tx_extbase_core_bootstrap->run
extensionName = Addthis
pluginName = Pi1
stdWrap {
wrap = <section class="share">|</section>
@markhowellsmead
markhowellsmead / nextprevious.ts
Created May 21, 2014 11:49
Next/previous navigation using TypoScript in TYPO3
# Next / previous
# Generates links to the previous and next pages in the same level as the current page
# Define the terms for "next page" and "previous page" in the TS constants, or amend
# the following code to use Locallang files.
# 17.12.2013 mhm.li | m@mhm.li
lib.nextprevious = COA
lib.nextprevious {
wrap = <div class="turn">|</div>
@markhowellsmead
markhowellsmead / unpack.ssh
Created June 16, 2014 08:19
Unpack files via command line (including via SSH connections)
# Unpack files via command line (including via SSH connections)
# www.mhm.li | m@mhm.li | 6/2014 | Free use, no credit required
If a file ends in .zip (for example, file.zip), type:
unzip file.zip
If a file ends in .tar (e.g., file.tar), type:
tar -xvf file.tar
If a file ends in .gz (for example, file.gz), type:
# Protect folder using htpasswd file
# www.mhm.li | m@mhm.li | 6/2014 | Free use, no credit required
AuthName "Private area"
AuthType Basic
AuthUserFile /path/to/webroot/.htpasswd
AuthGroupFile /dev/null
require valid-user
Order allow,deny
Allow from xxx.xxx.xx.xxx
@markhowellsmead
markhowellsmead / pagelink.fluid.html
Created June 19, 2014 13:04
TYPO3 ExtBase / Fluid - Create page link according to type of variable
@markhowellsmead
markhowellsmead / menu.html
Created June 25, 2014 14:23
Manual menu using TYPO3 Fluid syntax
# Create TYPO3 Fluid menu manually instead of automatically
# TYPO3 Extbase / Fluid
# www.mhm.li | m@mhm.li | 6/2014 | Free use, no credit required
<nav id="myMenu">
<ul>
<v:page.menu levels="4" expandAll="1">
<f:for each="{menu}" as="item">
<li class="{f:if(condition: item.active, then: 'act')}{f:if(condition: item.current, then: ' cur')}">
<f:link.page pageUid="{item.uid}" title="{item.title}">{item.title}</f:link.page>
@markhowellsmead
markhowellsmead / .htaccess
Last active May 19, 2016 07:37
CSS file versioning using htaccess file (Apache config)
# CSS file versioning using htaccess file (Apache config)
# Link to the file style.123456.css and the server will deliver style.css
# Change the number and the web browser will see it as a different file
# and force it to be loaded afresh
# permanenttourist.ch | mark@permanenttourist.ch | 6/2014 | Free use, no credit required
# Warning: use only numeric sequences for the version reference!
# Warning: if a file with the actual name really exists, it will be served!
RewriteCond %{REQUEST_FILENAME} !-s
@markhowellsmead
markhowellsmead / icl_link_to_element.php
Created July 9, 2014 11:19
WordPress WPML - generate link to translated version of a page