Skip to content

Instantly share code, notes, and snippets.

@Dobby89
Dobby89 / Commands.md
Last active April 9, 2024 12:29
Jest / React Testing Library

Only run tests against files which have been changed (--passWithNoTests used in case no tested files have changed)

jest --onlyChanged --passWithNoTests
@Dobby89
Dobby89 / helpers.md
Last active January 17, 2024 08:56
Typescript snippets

Helpers

Get a unique array

An array of primitives

[...new Set([1, 1, 2, 3])] // [1, 2, 3]
@yagudaev
yagudaev / cypress_support_hooks.js
Last active September 16, 2021 08:46
Cypress Fetch Support Workaround - replaces fetch request with traditional XHR so cypress can track them
// cypress/support/hooks.js
// Cypress does not support listening to the fetch method
// Therefore, as a workaround we polyfill `fetch` with traditional XHR which
// are supported. See: https://github.com/cypress-io/cypress/issues/687
enableFetchWorkaround()
// private helpers
function enableFetchWorkaround() {
let polyfill
@nardan
nardan / nuke-modules.ps1
Last active March 18, 2020 07:50
Deleting Node Modules
Get-ChildItem -Path "." -Include "node_modules" -Recurse -Directory | Remove-Item -Recurse -Force
function makeIndex() {
return Math.random().toString(12).substring(2, 12);
}
function Awesome() {
Object.defineProperty(this, 'index', {
writable: false,
configurable: false,
value: makeIndex()
});
@agorilla
agorilla / _map-get-next.scss
Last active March 7, 2020 11:01
Sass function map-get-next
/// Function to get next map item
/// returns next map item or fallback value if map, key or next item does not exist
/// Github Repo: https://github.com/elcheio/sass-map-get-next-prev
/// Node Module: https://www.npmjs.com/package/sass-map-get-next-prev
///
/// @author Simon Koch <agorilla@me.com>
///
/// Licensed under the MIT license.
///
/// @access public
@Gaya
Gaya / responsive-svg-sprite-template.scss
Last active September 15, 2017 14:19
Responsive SVG Sprite Mixin
/*
* Generate a SVG-sprite mixin for Sass
* ====================================
*
* Gaya Kessler - http://gaya.ninja - http://twitter.com/GayaNinja
*
* SVGSprite is a wonderful package, but doesn't enable responsive sprites out of the box.
* This moustache template generates a sass file with a mixin for the generated SVG-sprite.
* Calculates the position and size of the background by filename.
* Included SVG image scales to width and height.
@pbojinov
pbojinov / README.md
Last active June 24, 2024 05:39
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@patocallaghan
patocallaghan / example.html
Last active December 29, 2015 23:09
Mixin to do responsive sprites..Demo to follow...
<span class="logo" data-logo="examplelogo"></span>
<!-- By default the .logo element should span 100% width.
If you need it to be constrained in size use a container element with a width % value on it -->
<style>
.logo--header {
width: 25%;
}
</style>
<div class="logo--header">
@O-Zone
O-Zone / transitionEnd.js
Last active November 23, 2023 22:43
Get the name of the browsers transitionEnd event. After calling this, window.transitionEnd will contain the browser specific name of the transitionEnd event. This is an extract of EvandroLG's transitionEnd snippet, without all support for testing different elements and using cache.
(function (window) {
var transitions = {
'transition': 'transitionend',
'WebkitTransition': 'webkitTransitionEnd',
'MozTransition': 'transitionend',
'OTransition': 'otransitionend'
},
elem = document.createElement('div');
for(var t in transitions){