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 / axios.ts
Created December 7, 2021 12:52
Axios TypeScript Dump
import axios, { AxiosError, CancelTokenSource, AxiosRequestConfig } from 'axios';
// how to overide defaults
axios.defaults.baseURL = '/';
// axios.defaults.headers.common['Content-Type'] = 'application/json'; // for all requests
// axios.defaults.headers.get['Content-Type'] = 'application/json'; // for only gets
// axios.defaults.headers.post['Content-Type'] = `multipart/mixed`; // for only posts
axios.defaults.timeout = 90000; // timeout (very high by default)
{"v":"5.5.4","fr":60,"ip":0,"op":480,"w":48,"h":48,"nm":"Timer","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"seconds","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[235]},{"t":479,"s":[595]}],"ix":10},"p":{"a":0,"k":[24.375,23.781,0],"ix":2},"a":{"a":0,"k":[-21.625,0.32,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[4,16],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":100,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":0,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-21.625,0.5],"ix":2},"a":{"a":0,"k":[0,6.25
@sidonaldson
sidonaldson / React-component.js
Created June 26, 2017 14:37
SVG Sprite Loader issue
const Graphic = (props) => {
const {glyph, ...rest} = props;
let svg = null;
try {
svg = require('../../assets/svg/' + glyph + '.svg').default;
} catch (err) {
return null;
@sidonaldson
sidonaldson / yoast-acf-analysis.js
Created July 12, 2016 11:39
Amend to Yoast ACF SEO Analysis
YoastACFAnalysis.prototype.addAcfFieldsToContent = function(data) {
var acf_content = ' ',
parents = $('#post-body, #edittag');
// get text content
parents.find('input[type="text"][id^="acf"][value != ""][class != "wp-color-picker"], textarea[id^="acf"]:not(:empty)').each(function() {
acf_content += ' ' + $(this).val();
});
@sidonaldson
sidonaldson / contentful-cache.js
Created May 16, 2016 16:28
Node ExpressJS Contenful.js basic sync middleware example and routes
'use strict'
var contentful = require('contentful'),
util = require('util'),
async = require('async'),
fs = require('fs'),
_ = require('lodash'),
client = contentful.createClient({
space: 'ctupzx1pv75n',
accessToken: '601c31d2ec144e4d9e2dd4bd9771fef57ccf88d64ea722bca9ba2a749104d8a6'
@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 {}
@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 / 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 / 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 / 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' ] );