Skip to content

Instantly share code, notes, and snippets.

View ashhitch's full-sized avatar
💭
Slinging Divs

Ash Hitchcock ashhitch

💭
Slinging Divs
View GitHub Profile
@ashhitch
ashhitch / gatsby-image-graphql-toolkit.js
Created June 8, 2021 14:21
Gatsby Image in GraphQL toolkit
exports.createResolvers = function({ actions,cache,createNodeId,createResolvers,store,reporter }) {
const { createNode } = actions;
createResolvers({
HATCH_ContentMediaItemType: {
imageFile: {
type: `File`,
resolve(source, args, context, info) {
return createRemoteFileNode({
url: source.filePath,
@ashhitch
ashhitch / remove-search-yoast.php
Created December 7, 2020 16:20
remove search action Yoast SEO
<?php
add_filter('wpseo_schema_website', 'example_change_website');
function example_change_website($data)
{
if ($data['potentialAction']) {
foreach ($data['potentialAction'] as $key => $value) {
# code...
if ($value['@type'] && $value['@type'] == 'SearchAction') {
unset($data['potentialAction'][$key]);
@ashhitch
ashhitch / apollo-refreshToken-link.js
Created September 5, 2019 20:27 — forked from alfonmga/apollo-refreshToken-link.js
Apollo refresh auth token link. It tries to refresh user access token on the fly when API throws out an UNAUTHENTICATED error. If multiple requests fails at the same time it queues them to re-try them later if we are able to get a new access token, otherwise we logout the user and redirect him to the login page.
@ashhitch
ashhitch / providerCompose.js
Created April 30, 2019 12:29 — forked from stolinski/providerCompose.js
ProviderComposer
function ProviderComposer({ contexts, children }) {
return contexts.reduceRight(
(kids, parent) =>
React.cloneElement(parent, {
children: kids,
}),
children
);
}
@ashhitch
ashhitch / sw-src.js
Created June 28, 2018 20:39
workbox
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.3.0/workbox-sw.js');
//{clientsClaim: true}
//console.log('this is my custom service worker');
const revision = 'version-1';
const longerRevision = 'static-1';
//Config
workbox.setConfig({
debug: true
@ashhitch
ashhitch / docker-compose.yml
Last active March 19, 2018 10:53
Wordpress docker file
version: '3'
services:
wordpress:
depends_on:
- db
image: wordpress:4.9.4
restart: always
volumes:
- ./wp-content:/var/www/html/wp-content
environment:
@ashhitch
ashhitch / Template-Driven.html
Created January 5, 2018 13:59
Set default value for <select> in Angular 2+ Template Driven Forms
<select [ngModel]="field ||''">
<option value="">Select field</option>
<option *ngFor="let property of properties" [ngValue]="property">{{property.name}}</option>
</select>
@ashhitch
ashhitch / Reactive-Forms.html
Last active January 5, 2018 13:58
Set default value for <select> in Angular 2+ Reactive Forms
<select formControlName="field">
<option [ngValue]="null">Select field</option>
<option *ngFor="let property of properties" [ngValue]="property">{{property.name}}</option>
</select>
@ashhitch
ashhitch / getHiddenElementDimensions.ts
Created January 4, 2018 12:56
get Hidden Element Dimensions
getHiddenElementDimensions( element: any ): any {
let dimensions: any = {};
element.style.visibility = 'hidden';
element.style.display = 'block';
dimensions.width = element.offsetWidth;
dimensions.height = element.offsetHeight;
element.style.display = 'none';
element.style.visibility = 'visible';
return dimensions;
@ashhitch
ashhitch / viewport-width.ts
Created January 4, 2018 12:55
Angular Get viewport width
getViewport(): any {
let win = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
w = win.innerWidth || e.clientWidth || g.clientWidth,
h = win.innerHeight || e.clientHeight || g.clientHeight;
return {width: w, height: h};
}