Skip to content

Instantly share code, notes, and snippets.

View nfreear's full-sized avatar

Nick Freear nfreear

View GitHub Profile
@nfreear
nfreear / php-markdown-extra-autoid-toc.php
Created September 7, 2012 22:20
Run PHP-Markdown-Extra, optionally adding automatic IDs and contents table / (c) N.D.Freear
<?php
/**
* Run PHP-Markdown[-Extra] [-x], optionally adding automatic IDs [-a],
* and a table of contents [-ac].
*
* @copyright 2012-09-07 N.D.Freear.
*/
if (php_sapi_name() != 'cli') {
_error('must be in CLI mode.');
@nfreear
nfreear / git-log-pretty-grep-worktimes.sh
Created September 13, 2012 09:54
Find git logs that happened out of "office hours"
# With colours
$ git log -50 --pretty=format:'%Cred%h%Creset - %C(yellow)%ci%Creset - %s' --abbrev-commit | grep -m 2 -E "(0.|1[89]|2.):..:"
# No colours > CSV
$ git log -400 --pretty=format:'%h,%ci,"%s",%aN' --abbrev-commit | grep -E "(0.|1[89]|2.):..:" > git-log-grep-worktimes.csv
<!--Capret-widget starts (src=// below is deliberate)-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://track.olnet.org/capret/js/jquery.plugin.clipboard.js"></script>
<script src="http://track.olnet.org/capret/js/oer_license_parser.js"></script>
<!--[if lt IE 8]>
<script src="//cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js"></script>
<![endif]-->
<script
src="http://track.olnet.org/capret/js/capret-piwik.js"
data-piwik_idsite="6"
<!--Capret-widget begins-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script src="http://track.olnet.org/capret/js/jquery.plugin.clipboard.js"></script>
<script src="http://track.olnet.org/capret/js/oer_license_parser.js"></script>
<script src="http://track.olnet.org/capret/js/capret.js"></script>
<p><a rel="license" href="http://creativecommons.org/licenses/by/3.0/"><img alt="Creative Commons Licence" style="border-width: 0;" src="http://i.creativecommons.org/l/by/3.0/88x31.png" /></a>
<br />This work by <a xmlns:cc="http://creativecommons.org/ns#" href="http://labspace.open.ac.uk" property="cc:attributionName" rel="cc:attributionURL">Labspace - Bridge to success B2S</a> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 Unported License</a>.</p>
<p>This site is <a href="http://capret.mitoeit.org/">CaPRéT enabled</a>: Cut and Paste Reuse Tracking</p>
<!--Capret-widget ends-->
@nfreear
nfreear / pdftohtml-example.php
Created October 17, 2012 14:41
PDF to HTML conversion in PHP
<?php
// Standalone context.
define('PDFTOHTML_PATH', 'X:/PATH TO/workspace/_ouplayer_data/pdftohtml-0.39/pdftohtml.exe'); # Windows.
#define('PDFTOHTML_PATH', '/usr/bin/pdftohtml'); # Redhat 6.
require_once 'libraries/pdftohtml.php';
//( Or, CodeIgniter context. )
#$config['pdftohtml_path'] = '/usr/bin/pdftohtml';
#$this->load->library('pdftohtml');
@nfreear
nfreear / persona-accessibility.html
Created October 18, 2012 12:48
A Mozilla Persona demo, with 'correct' <button> markup, for accessibility | https://login.persona.org
<!doctype html><html><title>*Mozilla Persona</title>
<style>
button#signin {
background: url(http://developer.mozilla.org/files/3963/persona_sign_in_blue.png) no-repeat; /*185 x 25*/
width: 189px;
height: 29px;
}
button#signin, #signin-img {
cursor: pointer;
@nfreear
nfreear / labspace-capret-piwik-cc-by-js.v6.htm
Created November 13, 2012 16:39
CaPRéT-Piwik: Cut & Paste Reuse Trac.., http://capret.mitoeit.org -- for OpenLearn-LabSpace/B2S | http://track.olnet.org/test/capret/math/course-piwik
<!--Capret-widget starts (src=// below is deliberate)-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script
src="http://track.olnet.org/capret/build/capret-piwik.min.js"
data-piwik_idsite="6"
data-piwik_debug="1"
></script>
<p><a rel="license" href="http://creativecommons.org/licenses/by/3.0/"><img
alt="Creative Commons Licence" style="border-width: 0;"
@nfreear
nfreear / labspace-capret-ga-cc-by-js.v7.html
Created November 14, 2012 09:50
CaPRéT-Google Analytics: Cut & Paste Reuse Trac.., http://capret.mitoeit.org -- for OpenLearn-LabSpace/B2S | http://track.olnet.org/test/capret/math/course-ga
<!--Capret-widget starts (src=// below is deliberate)-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script
src="http://track.olnet.org/capret/build/capret-ga.min.js"
data-utm_ac="UA-34064304-5"
data-utm_debug="1"
></script>
<p><a rel="license" href="http://creativecommons.org/licenses/by/3.0/"><img
alt="Creative Commons Licence" style="border-width: 0;"
@nfreear
nfreear / youtube-width-100percent.html
Created November 14, 2012 16:36
Test of <iframe> width=100% using YouTube
<!doctype html><meta charset=utf-8 /><title>*iframe width=100% test</title>
<style>
.region-0{ width:420px; border:1px solid #ccc; padding:.5em; }
iframe{ overflow:hidden; border:none; min-width:240px; }
</style>
<div class=region-0>
<h1>iframe width=100%</h1>