Skip to content

Instantly share code, notes, and snippets.

View mgrubinger's full-sized avatar

Martin Grubinger mgrubinger

View GitHub Profile
import { build, files, version } from '$service-worker';
// https://github.com/microsoft/TypeScript/issues/11781 - this is needed for TS and ESLint
/// env serviceworker
const globalThis = /** @type {unknown} */ (self);
/// <reference no-default-lib="true"/>
/// <reference lib="es2020" />
/// <reference lib="WebWorker" />
const sw = /** @type {ServiceWorkerGlobalScope & typeof globalThis} */ (globalThis);
@paulmwatson
paulmwatson / cypress_test_404_spec.js
Created January 14, 2021 08:33
Testing a 404 page with Cypress
cy.visit('/404')
//=> Test fails
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes but does not test the HTTP code was 404
cy.request({url: '/404', failOnStatusCode: false}).its('status').should('equal', 404)
cy.visit('/404', {failOnStatusCode: false})
//=> Test passes, tests that the HTTP code was 404, and tests page was visited
@srdjan
srdjan / 100+ different counter apps...
Last active May 6, 2024 05:13
100+ different js counter apps...
100+ different js counter apps...
@lilgreenland
lilgreenland / platformer (matter-js).markdown
Last active March 25, 2020 01:01
platformer (matter-js)
@xenozauros
xenozauros / hex2hsl.js
Last active May 7, 2024 09:21
Javascript: HEX to RGB to HSL
function hexToHSL(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
r = parseInt(result[1], 16);
g = parseInt(result[2], 16);
b = parseInt(result[3], 16);
r /= 255, g /= 255, b /= 255;
var max = Math.max(r, g, b), min = Math.min(r, g, b);
var h, s, l = (max + min) / 2;
if(max == min){
h = s = 0; // achromatic
@ankurk91
ankurk91 / git_remember_password.md
Last active May 17, 2024 03:46
Git credential cache, why type password again and again

Tired of entering password again and again ?

Run this command to remember your password:

git config --global credential.helper 'cache --timeout 28800'

Above command will tell git to cache your password for 8 hours.

@zeroseis
zeroseis / disable-auto-android-file-transfer.md
Created September 14, 2015 17:28
Disable auto start for Android File Transfer
  • Close Android File Transfer
  • Open Activity Monitor and kill “Android File Transfer Agent”
  • Go to where you installed “Android File Transfer.app” (I have it under /Applications)
  • Ctrl+click –> “Show package contents”
  • Go to Contents/Resources
  • Rename “Android File Transfer Agent” to e.g. “Android File Transfer Agent_DISABLED”
  • Then go to “/Users/username/Library/Application Support/Google/Android File Transfer” and again rename the Agent app.
@cletusw
cletusw / .eslintrc
Last active February 29, 2024 20:24
ESLint Reset - A starter .eslintrc file that resets all rules to off and includes a description of what each rule does. From here, enable the rules that you care about by changing the 0 to a 1 or 2. 1 means warning (will not affect exit code) and 2 means error (will affect exit code).
{
// http://eslint.org/docs/rules/
"ecmaFeatures": {
"binaryLiterals": false, // enable binary literals
"blockBindings": false, // enable let and const (aka block bindings)
"defaultParams": false, // enable default function parameters
"forOf": false, // enable for-of loops
"generators": false, // enable generators
"objectLiteralComputedProperties": false, // enable computed object literal property names
@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

@nfreear
nfreear / wai-aria.use.css
Created December 3, 2013 15:13
CSS bookmarklet to highlight WAI-ARIA landmark roles etc. | Inspired by the Juicy Studio Accessibility toolbar - works in Chrome..
/*!
CSS bookmarklet to highlight WAI-ARIA landmark roles etc.
NDF, 3 December 2013.
http://w3.org/TR/wai-aria/roles#landmark_roles
Inspiration: https://addons.mozilla.org/en-US/firefox/addon/juicy-studio-accessibility-too/
javascript:(function(){
var D=document,s=D.createElement("link");s.href="//dl.dropbox.com/u/3203144/wai-aria/wai-aria.css";s.rel="stylesheet";D.head.appendChild(s)