Skip to content

Instantly share code, notes, and snippets.

View mrcleanandfresh's full-sized avatar

Kevin Dench mrcleanandfresh

  • Denver, USA
View GitHub Profile
@mrcleanandfresh
mrcleanandfresh / counting-banner.test.tsx
Last active April 13, 2020 18:08
I am having a problem properly mocking this single function in a way where I can overwrite it for each test case.
import { mount } from 'enzyme';
import fetchMock from 'jest-fetch-mock'
import React from 'react';
import { act } from 'react-dom/test-utils';
import { getCountStatus } from '../../services/__mocks__/counts.service';
import CountingBanner from '../counting-banner';
jest.mock('../../services/api/counts.service', () => ({
getCountStatus() {
return jest.fn();
@mrcleanandfresh
mrcleanandfresh / useMeasure.js
Created February 4, 2020 22:37 — forked from stolinski/useMeasure.js
useMeasure - taken from React Spring example
import { useRef, useState, useEffect } from 'react'
import ResizeObserver from 'resize-observer-polyfill'
export default function useMeasure() {
const ref = useRef()
const [bounds, set] = useState({ left: 0, top: 0, width: 0, height: 0 })
const [ro] = useState(() => new ResizeObserver(([entry]) => set(entry.contentRect)))
useEffect(() => (ro.observe(ref.current), ro.disconnect), [])
return [{ ref }, bounds]
}
@mrcleanandfresh
mrcleanandfresh / super-list-infinite.tsx
Last active May 17, 2021 16:53
React Virtualized Infinite loader with List example using React Hooks
import faker from 'faker';
import _ from 'lodash';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Col, Row } from 'react-bootstrap';
import { AutoSizer, IndexRange, InfiniteLoader, List, ListRowProps } from 'react-virtualized';
import wait from 'waait';
import { SuperProps } from './super-props';
export interface SuperListProps {
/**
@mrcleanandfresh
mrcleanandfresh / readme.md
Created December 30, 2015 16:43 — forked from hitautodestruct/readme.md
Generate a custom structure for Wordpress menus.

This gist is for showing an example of a custom wordpress menu.

If you want to get more from the menu item simply have a look at the $item object. i.e:

// Will return a large object with lots of props like title, url, description, id etc.
var_dump( $item );

This code works on Wordpress 4.1.1 as of 31st of March 2015

@mrcleanandfresh
mrcleanandfresh / fabfile.y
Created October 24, 2015 04:36 — forked from grega/fabfile.py
Sample Fabric 'fabfile' for deploying to multiple hosts. Using: `fab deploy stage` or `fab deploy live`. Deploy to live prompts the user to confirm (with 'y' or 'n') that they actually want to deploy. Deploy tasks runs git pull & any number of utility commands (eg. asset compilation, checking / fixing folder permissions etc).
from __future__ import with_statement
from fabric.api import env, local, settings, abort, run, cd, sudo
from fabric.contrib.console import confirm
# Hosts
def stage():
env.user = 'deploy_user'
env.hosts = ['xxx.xxx.xxx.xxx:22']
global code_dir
code_dir = '/var/www/stage.website.com' # no trailing slash
@mrcleanandfresh
mrcleanandfresh / SassMeister-input-HTML.html
Created October 16, 2015 14:54
Generated by SassMeister.com.
<h1>Lorem Ipsom</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tortor lorem, molestie ac magna laoreet, lobortis pellentesque tortor. Vivamus non mollis ipsum, sit amet blandit odio. Sed eleifend turpis erat, nec tempus sapien convallis id. Etiam dignissim sit amet quam nec rutrum. Nam in sagittis ex. Praesent gravida in leo non volutpat. Integer lacinia ac magna ut mollis. Proin at neque at augue tempus iaculis. Nam at est dolor. Cras ipsum leo, venenatis non auctor vitae, faucibus ac nisl. Donec dictum, ex sit amet tempor condimentum, lorem nisi condimentum tortor, at luctus augue nisl ut est. Praesent vel maximus mauris. Praesent ac fringilla tellus. Vestibulum lorem purus, maximus convallis sem eu, accumsan pharetra lacus. In elementum ante ligula, id molestie nisi lacinia sed. Fusce tempor dictum ipsum sit amet posuere.</p>
<h2>Lorem Ipsom</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tortor lorem, molestie ac magna laoreet, lobortis pellentesque tortor. Vivamus
<div id="response">
</div>