Skip to content

Instantly share code, notes, and snippets.

View furzeface's full-sized avatar
🤡
I may be slow to respond.

Daniel Furze furzeface

🤡
I may be slow to respond.
View GitHub Profile
@furzeface
furzeface / removing-gist-styles.js
Last active December 31, 2015 04:28
Removing GitHub Gists default styles from your <body> before styling them yourself.
var domLinks = document.getElementsByTagName('link'); // Get all the <link>'s
// Will most likely find stylesheets but will find any with rels eg rel="canonical/author/external..."
// Unfortunately we can't just traverse the <head> as the Gist stylesheet is embedding with the Gist in your pages <body>
var gistLinks = [];
for (var i = 0, l = domLinks.length; i < l; i++) {//loop 'em
var el = domLinks[i]; //current link
// If 'gist' is in the href -
if (el.href.indexOf('gist') > -1) {
@furzeface
furzeface / Anchor CMS config bootstrap
Last active January 2, 2016 03:49
To allow you to use one db.php file for all local dev/staging/production environments with Anchor CMS.
//Goes in your anchor/config/db.php file
//$$REPLACE_THESE$$ with your demo and live db details
switch ($_SERVER['SERVER_NAME']) {
case 'demo.domain.com': //eg. 'demodaniel.furzeface.com' for me
return array(
'default' => 'mysql',
'prefix' => 'anchor_', //change if you want
@furzeface
furzeface / Media Query Mixin
Last active August 22, 2016 03:45
My Sass Media Query Mixin...cos I keep forgetting to share this.
//=My breakpoint variables
//Usually kept in _variables.scss
$breakpoint-extra-small: 20em; //320px
$breakpoint-small: 30em; //480px
$breakpoint-medium: 50em; //800px
$breakpoint-extra-medium: 65em; //1040px
$breakpoint-large: 80em; //1280px
$breakpoint-extra-large: 100em; //1600px
@furzeface
furzeface / standard-media-queries.css
Last active May 25, 2017 19:01
A set of standard media queries for popular devices.
@media all and (min-device-width : 320px)
and (max-device-width : 480px) {
/*style all the things*/
}
@media all and (max-width : 320px) {
/*style all the things*/
}
@furzeface
furzeface / GitHub Gist Basic Styles
Created December 12, 2013 19:13
GitHub Gists default CSS selectors and base styles.
.gist {
color: #000;
.render-container {
.render-viewer-error,
.render-viewer-fatal,
.octospinner {
display: none;
}
}
@furzeface
furzeface / ITCSS.sh
Created June 14, 2018 13:18
ITCSSify things. I keep needing to do this when refactoring legacy projects.
#!/bin/bash
mkdir -p ./src/styles
touch ./src/styles/main.scss
mkdir -p ./src/styles/{base,components,generic,objects,settings,tools,trumps}
touch ./src/styles/{base,components,generic,objects,settings,tools,trumps}/__index.scss
echo "// Base - Unclassed HTML elements (type selectors)" > ./src/styles/base/__index.scss
echo "// Components - Designed components, chunks of UI" > ./src/styles/components/__index.scss
echo "// Generic - Ground-zero styles (normalize, resets, box-sizing etc)" > ./src/styles/generic/__index.scss
@furzeface
furzeface / google-analytics-custom-event-tracking-function.js
Last active October 18, 2018 13:42
A function to return the custom event tracker for Google Analytics, wrapped so if GA is not set up for local/demo environments JavaScript won't go mental!Plus, attaching it to a standard jQuery event listener.
// Wrap it so if GA is not initialised it doesn't go 'undefined'!
function analytics_custom_event_tracker(name, event, label)
{
if (typeof ga === 'function')
{
return ga('send', 'event', name, event, label);
}
}
@furzeface
furzeface / result.js
Created October 25, 2018 14:49
Reusable result snippet
result = result && result.result ? result.result : result;
@furzeface
furzeface / replace-svg-with-png.js
Last active March 26, 2023 09:14
The snippets I found online to replace svg with png for legacy browsers using Modernizr were all a little flaky, so here's what I wrote.
// Use Modernizr to check
if (!Modernizr.svg) {
// Using jQuery
$('img').each(function () { // Could also be more specific if you know where the svg's will be e.g. $('#work-content img')
var $img = this, // Cache current image DOM element in a variable
src = $img.src.split('.'), // Split the source
extension = src[src.length - 1]; // Make sure it's the last part of the split string
if (extension === 'svg') {
src[src.length - 1] = 'png'; // If it's svg, do all the things