Skip to content

Instantly share code, notes, and snippets.

View jeremypage's full-sized avatar

Jeremy Page jeremypage

  • Trafford Council
  • UK
View GitHub Profile
@jeremypage
jeremypage / regex-tips.md
Last active May 17, 2016 11:45
Regex tips and snippets

HTML: Demote all (second) duplicate H1 tags to H2

Search

((<h1>[^<]*<\/h1>)(.|\s)+?)<h1>([^<]*)<\/h1>

Replace

@jeremypage
jeremypage / check-tls.js
Last active January 31, 2019 10:40
JavaScript: Check TLS level of browser and remove matching domain links from page if browser does not meet minimum requirement
// domains to check
var checkDomains = ['www.foobar.com', 'www.fubar.com'];
// check all links in DOM for matching domain(s)
var matchingLinks = [];
var documentLinks = document.links;
for (var i = 0; i < documentLinks.length; i++) {
if (checkDomains.indexOf(documentLinks[i].hostname) > -1)
matchingLinks.push(documentLinks[i]);
}
@jeremypage
jeremypage / big-red-ordered-list.css
Created December 12, 2015 10:55
CSS: Ordered list with big red circular numbers. Derived from http://patternlab.io/css/style.css
ol {
list-style: none;
margin: 0;
padding: 0;
counter-reset: big-num;
}
ol li {
counter-increment: big-num;
position: relative;
@jeremypage
jeremypage / intranet-snow.js
Last active December 1, 2019 08:24
Put 'snow' on our corporate Intranet. Uses RequireJS and jQuery Snowfall (https://github.com/loktar00/JQuery-Snowfall)
require.config({
paths: {
"jquery": "/site-elements/scripts/jquery-3.3.1.min",
"jquerySnowfall": "/site-elements/scripts/vendor/snowfall.jquery.min"
}
});
define(["jquery", "jquerySnowfall"], function($){
var flake = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA2CAYAAACIsLrgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAcSSURBVGhD7ZhZaJ1FFMfjvrRqtVptbd2qrdatcUdrUagbjbSiVIgiLqgQ8a2gEBGfJIaKiEtqEEkMhLwZCjEvgeQhCU0hIQGbYEjIrgkhG23MTv3/PuZcxq83Tb6be6+C98CfTGbm/M+cOWfOzHezMpKRjGQkI/9XOS9B/CfEX9D5Hi6ICF/X50yr+E6wqAsdLvJw8Qrw55q+72BanTKHzBlz4BKHS1cJm28O+k6lzSFzxneExV0mXC6sE9Y7XLEMbJy56KALh+9YWpzynbGIsJh1k5OTr46MjDyv9gbhauEah40hWD9zNqCDrto4B5dFLOVOQQxICXaRHWV317e2tu5YWlqaW1xcHK+srNzZ39//0szMzM9q79L4ZmGLw2b6GGMOc9FBFw64BDjhxga2UuqQRYddxDDpQ0Q2LiwsHD8jmZ6e/lHtHtpDQ0MfauxWH/QxxhzmuvZxOAS44IQbGxallAjE7BjpQGqYM9cKN3R0dDynnV5kgcj8/Hz7/v3779EYUYqBPsbctDPooAuHAJc5hQ1spSRK4VQjNQJnWlpaHidl3Ppi0tzc/LbOx9Gurq5PNO8hQJs+xty0mMABF5yOGxuWekmPkp9qHN6rBAxvbmho2BvPobGxsUr+zs3N9WneXkDbH/MFDrjgdNz
@jeremypage
jeremypage / llpg-search.js
Last active October 21, 2017 08:10
JavaScript LLPG search control. Insert the script tag (<script type="text/javascript" id="llpg-address-search" src="llpg-search.js"></script>) into the body where the search link is to appear. Dependent on jQuery, jQueryUI and Handlebars.
(function ($) {
$(function () {
// Create cache objects to store results (minimizes repeat AJAX calls)
var searchCache = {}, addressCache = {};
// Our LLPG address search services
var searchURL = '//intranet.trafford.gov.uk/AddressService/Service.svc/jsonp/SearchLLPGAddress/';
var addressDetailsURL = '//intranet.trafford.gov.uk/AddressService/Service.svc/jsonp/GetLLPGAddressById/';
// Search form markup and styling
@jeremypage
jeremypage / wget-entire-site-copy.cmd
Created December 7, 2015 10:51
WGET: Get entire contents of given website. Ignores robots.txt to ensure all content is retrieved. Uses local proxy (CNTLM) to negotiate corporate proxy.
wget -e http_proxy=127.0.0.1:3128 robots=off --recursive --no-clobber --page-requisites --html-extension --convert-links --domains www.foobar.com www.foobar.com
@jeremypage
jeremypage / tscb-logo.svg
Created November 26, 2015 09:31
TSCB logo
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jeremypage
jeremypage / 45-75.js
Created November 23, 2015 12:50
Bookmarklet to high light optimum line reading length (45-75 characters). From CSS-Tricks (https://css-tricks.com/bookmarklet-colorize-text-45-75-characters-line-length-testing/)
javascript:(function(){function loadScript(a,b){var c=document.createElement('script');c.type='text/javascript';c.src=a;var d=document.getElementsByTagName('head')[0],done=false;c.onload=c.onreadystatechange=function(){if(!done&&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;b()}};d.appendChild(c)}loadScript('//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js',function(){var redOutline={outline:'2px solid red'},text;var textyElements='p, li, dt, dd, h1, h2, h3, h4, h5, h6';$(textyElements).on('mouseover.red',function(){$(this).css(redOutline)}).on('mouseleave.red',function(){$(this).removeAttr('style')}).on('click.red',function(){text=$(this).text();var e=text.substring(0,45);var t=text.substring(45,75);var n=text.substring(75,text.length);var r=e+'<span style=\'color: red;\'>'+t+'</span>'+n;$(this).html(r);$(textyElements).off('mouseover.red mouseleave.red click.red');$(this).removeAttr('style');})})})()
@jeremypage
jeremypage / git-loglive
Last active November 26, 2015 15:25 — forked from tlberglund/git-loglive
Log Live Git Command
#!/bin/sh
while :
do
clear
git log --graph --all --color --date=short -20 --pretty=format:"%C(yellow)%h%x20%C(white)%cd%C(green)%d%C(reset)%x20%s%x20%C(bold)(%an)%Creset" |
cat -
sleep 10
done
@jeremypage
jeremypage / log4net-boilerplate.cs
Created September 15, 2015 10:31
Log4net: Boilerplate code
public class Foo
{
private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
... other code
}