Skip to content

Instantly share code, notes, and snippets.

View sloyless's full-sized avatar
👓

Sean Loyless sloyless

👓
View GitHub Profile
@sloyless
sloyless / jestGlobals.js
Last active May 6, 2025 16:19
Helpful Jest Mocks
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
import fetch from 'isomorphic-fetch';
import { Animated, NativeModules } from 'react-native';
// General React Mocks
global.fetch = jest.fn(() => Promise.resolve({
ok: true,
json: () => Promise.resolve({})
}));
global.navigator = { geolocation: () => {} };
@sloyless
sloyless / index.html
Last active April 19, 2021 15:18
2021 HTML Boilerplate
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>Unique page title - My Site</title>
<script type="module">
document.documentElement.classList.remove('no-js');
@sloyless
sloyless / stuff.md
Last active November 3, 2022 17:51
Helpful Linux term commands

Allow insecure HTTPS

chrome://flags/#allow-insecure-localhost

Fix node.js global permissions:

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

Fix permissions issues

sudo chmod -R 777 - do not use this on the root of the drive or system folders!

Copy entire directories

@sloyless
sloyless / smooth-scrolling.css
Created October 1, 2019 20:45
CSS Smooth scrolling!
html {
scroll-behavior: smooth;
}
.overflow-y-window {
height: 80vh;
overflow-y: scroll;
scroll-behavior: smooth;
}
@sloyless
sloyless / firefoxmargin.css
Created October 18, 2017 21:51
Firefox Weird Margin Issues
// This is to accommodate weird spacing issues in Firefox only.
@-moz-document url-prefix() {
margin-top: 10px;
}
@sloyless
sloyless / grid.scss
Last active January 2, 2019 12:37
CSS Grid with Flexbox fallback
// Based on https://css-tricks.com/browser-compatibility-css-grid-layouts-simple-sass-mixins/
// This CSS Grid mixin and styles allow modern browsers to use the newer display: grid functionality,
// but allow a fallback to Flexbox to support older browsers like IE 11.
@mixin basic-styles {
display: flex;
align-items: center; // Vertically center all content
}
@mixin grid-child ($col-start, $col-end, $row-start, $row-end) {
@sloyless
sloyless / loading-dots.scss
Last active May 2, 2017 17:21
Loading dot animation CSS
@keyframes blink {
/**
* At the start of the animation the dot
* has an opacity of .2
*/
0% {
opacity: .2;
}
/**
* At 20% the dot is fully visible and
@sloyless
sloyless / spin.css
Last active April 23, 2017 17:24
Forever spinning and pulsing graphic
img {
animation-name: rotate;
animation-duration: 0.75s;
animation-fill-mode: none;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
@keyframes rotate {
0% {
@sloyless
sloyless / numeric-input.html
Last active February 19, 2017 01:05
iPhone/Android numeric input pad
<input id="quantity" class="form-control" type="number" name="quantity" placeholder="Enter Number" inputmode="numeric" pattern="[0-9]*" />
@sloyless
sloyless / fallback-image.html
Last active April 13, 2017 14:41
Fallback Image if missing
<img src="logo.png" alt="" onerror="if (this.src != 'default.png') this.src = 'default.png';"/>