Skip to content

Instantly share code, notes, and snippets.

View elidupuis's full-sized avatar

Eli Dupuis elidupuis

View GitHub Profile
@elidupuis
elidupuis / ember-intl-setup-codemod.js
Last active November 13, 2023 22:33
ember-intl v6 migration codemod
// Install jscodeshift globally if you haven't already
// npm install -g jscodeshift
/**
* ember-intl-setup-codemod.js
* This codemod is to help deal with the ember-intl v5 to v6 migration.
* Specfically, the "Missing setupIntl() results in a runtime error" error.
*
* All it does is add the following lines:
*
@elidupuis
elidupuis / README.md
Last active September 18, 2023 17:39
Service worker `getNotifications()` test snippet

tl;dr

The service worker registration method getNotifications() never fulfills (neither resolves nor rejects) in MS Edge on macOS if notification permissions have been granted by the user.

Details

The bug appears to only exist if Notification.permission === 'granted', meaning that the user has granted permissions for notifications at the browser level. This bug has been experienced in Microsoft Edge on macOS, versions 86, 87 (beta), and 88 (dev). It does not appear to be present on Windows.

You can easily test this on any PWA application. First, you'll need to manually toggle notification permissions (granted is the only state where the bug exists) and then simply run the test snippet into your browser console.

@elidupuis
elidupuis / bookmarklet.js
Created May 13, 2011 17:19
How to create a bookmarklet with an external js file.
// use this code as your href attribute on your 'Install this bookmarklet' anchor tag.
// borrowed from http://net.tutsplus.com/tutorials/javascript-ajax/create-bookmarklets-the-right-way/
javascript:(function(){var jsCode = document.createElement('script');jsCode.setAttribute('src', 'http://example.com/path/to/file.js');document.body.appendChild(jsCode);}());
@elidupuis
elidupuis / README.md
Last active January 8, 2023 15:36
Path from mouse or touch input

Simple Drawing Example

Click and drag your mouse (or finger on touch device) to draw a line. A new path is created for each touch or click.

Paths are stored in a nested array; you can inspect the variable in console: session (assuming the example is in it's own window).

@elidupuis
elidupuis / handlebars-helpers.js
Last active December 7, 2021 02:24
Simple Handlebars.js helpers
/*! ******************************
Handlebars helpers
*******************************/
// debug helper
// usage: {{debug}} or {{debug someValue}}
// from: @commondream (http://thinkvitamin.com/code/handlebars-js-part-3-tips-and-tricks/)
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
import Ember from 'ember';
import { A } from '@ember/array';
import { parallel } from 'ember-animated';
import move from 'ember-animated/motions/move';
import scale from 'ember-animated/motions/scale';
import { fadeIn, fadeOut } from 'ember-animated/motions/opacity';
import adjustCSS from 'ember-animated/motions/adjust-css';
import { easeIn, easeOut, easeInAndOut } from 'ember-animated/easings/cosine';
export default Ember.Controller.extend({
@elidupuis
elidupuis / application.adapter.js
Last active December 25, 2019 18:18
Extended Models with custom adapter and serializer
import DS from 'ember-data';
export default DS.RESTAdapter.extend({
namespace: 'api',
pathForType(modelName) {
let dasherized = Ember.String.dasherize(modelName);
if (/^job-/.test(modelName)) {
dasherized = 'job';
@elidupuis
elidupuis / controllers.application.js
Last active July 10, 2019 19:16
Parent animator offset x & y
import Ember from 'ember';
import move from 'ember-animated/motions/move';
import { fadeIn, fadeOut } from 'ember-animated/motions/opacity';
import adjustCSS from 'ember-animated/motions/adjust-css';
import { easeIn, easeOut, easeInAndOut } from 'ember-animated/easings/cosine';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
isThingActive: false,
@elidupuis
elidupuis / controllers.application.js
Last active July 9, 2019 20:43
Parent animator offset position
import Ember from 'ember';
import move from 'ember-animated/motions/move';
import { fadeIn, fadeOut } from 'ember-animated/motions/opacity';
import { easeIn, easeOut, easeInAndOut } from 'ember-animated/easings/cosine';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
isThingActive: false,
@elidupuis
elidupuis / controllers.application.js
Last active July 9, 2019 20:26
Parent animator offset via private API
import Ember from 'ember';
import move from 'ember-animated/motions/move';
import { fadeIn, fadeOut } from 'ember-animated/motions/opacity';
import { easeIn, easeOut, easeInAndOut } from 'ember-animated/easings/cosine';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
isThingActive: false,