Skip to content

Instantly share code, notes, and snippets.

View sidonaldson's full-sized avatar
🐢
I like turtles

Simon Donaldson sidonaldson

🐢
I like turtles
View GitHub Profile
@sidonaldson
sidonaldson / disable_overscroll.css
Last active August 29, 2015 14:27
Disable 'overscroll'
html {
overflow: hidden;
height: 100%;
}
body {
height: 100%;
overflow: auto;
}
@sidonaldson
sidonaldson / sample.editorconfig
Last active November 23, 2015 17:33
Generic .editorconfig file
# This is the root editor config file
root = true
# Apply rules to all files
[*]
# Use unix line endings
end_of_line = lf
insert_final_newline = true
@sidonaldson
sidonaldson / sample.jshintrc
Created September 8, 2015 11:50
Generic .jshintrc file
{
"node": true, // Enable globals available when code is running inside of the NodeJS runtime environment.
"browser": true, // Standard browser globals e.g. `window`, `document`.
"esnext": true, // Allow ES.next specific features such as `const` and `let`.
"bitwise": false, // Prohibit bitwise operators (&, |, ^, etc.).
"camelcase": false, // Permit only camelcase for `var` and `object indexes`.
"curly": false, // Require {} for every new block or scope.
"eqeqeq": true, // Require triple equals i.e. `===`.
"immed": true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
"latedef": true, // Prohibit variable use before definition.
@sidonaldson
sidonaldson / tame-tinymce.php
Created October 30, 2015 11:36
This snippet will tame TinyMCE within Wordpress and prevent it trying to clean up the code and reformat it. Specifically helps to prevent wordpress strip p tags and line-breaks and stops it from inserting nbsp etc
function mce_mod( $init ) {
$init['forced_root_block'] = 'p';
$init['apply_source_formatting'] = false;
$init['preformatted'] = true;
$init['force_br_newlines'] = true;
$init['wpautop'] = false;
return $init;
}
add_filter('tiny_mce_before_init', 'mce_mod', 99);
@sidonaldson
sidonaldson / Stylus override margin and padding with default variables
Last active December 30, 2015 21:01
This stylus mixin overrides the default CSS margin and padding properties so that you can pass size strings such as 'xl' etc
margin-xs := 0.2rem
margin-s := 0.4rem
margin-m := 0.6rem
margin-l := 1rem
margin-xl := 10rem
padding-xs := 0.2rem
padding-s := 0.4rem
padding-m := 0.6rem
padding-l := 1rem
padding-xl := 1.5rem
@sidonaldson
sidonaldson / Disable Wordpress oEmbeds feature
Created January 22, 2016 15:20
Add this to functions.php to remove the auto-embed feature of WP >=4
remove_shortcode( 'embed' );
remove_filter( 'the_content', [ $GLOBALS['wp_embed'], 'autoembed' ], 8 );
remove_filter( 'the_content', [ $GLOBALS['wp_embed'], 'run_shortcode' ], 8 );
remove_action( 'edit_form_advanced', [ $GLOBALS['wp_embed'], 'maybe_run_ajax_cache' ] );
@sidonaldson
sidonaldson / wordpress-open-sans.php
Created January 27, 2016 15:24
Remove Open-Sans from Wordpress Admin
function replace_admin_open_sans() {
wp_deregister_style( 'open-sans' );
wp_register_style( 'open-sans', false );
wp_enqueue_style( 'open-sans', '' );
}
add_action( 'init', replace_admin_open_sans');
@sidonaldson
sidonaldson / angular-ajax-interceptor.js
Created April 5, 2016 10:28
How to add an Interceptor to log all AJAX requests in AngularJS
angular.module('test-app')
.factory('myHttpInterceptor', ['$q', function($q) {
return {
'response': function(res) {
console.log('New request', res, res.headers());
return res || $q.when(res);
},
'responseError': function(rej) {
if (canRecover(rej)) return responseOrNewPromise;
@sidonaldson
sidonaldson / scrollbars.css
Created April 25, 2016 15:31
Force Scrollbars to appear (even with magic mouse)
div{
overflow-y: scroll;
}
div::-webkit-scrollbar {
width: 9px;
}
div::-webkit-scrollbar-track {
border-radius: 5px;
background: rgba(0,0,0,0.1);
}
@sidonaldson
sidonaldson / mailchimp-basic-subscribe.css
Last active May 6, 2016 14:42
A really simple vanilla form to subscribe to a Mailchimp list. Gracefully degrades if JavaScript is disabled.
.mailchimp {}
.mailchimp__email {}
.mailchimp__spamnet {
position: absolute;
left: -5000px;
}
.mailchimp__submit {}