Skip to content

Instantly share code, notes, and snippets.

@mikemunsie
mikemunsie / sampleHook.ts
Last active July 24, 2023 15:19
Inject Vue Hook Context into Child Components
import { ref } from "vue";
import useContext from "../utils/useContext";
const useSampleHook = (userDefinedName) => {
const name = ref(userDefinedName);
return {
name,
refreshData,
};
};
@mikemunsie
mikemunsie / vue-setup.md
Last active September 20, 2018 16:22
Vue Setup

jsconfig.json

@mikemunsie
mikemunsie / myClass.js
Created February 9, 2018 03:50
Auto-Bind all methods in an es6 class
class MyClass {
constructor() {
Object.getOwnPropertyNames(this.constructor.prototype).forEach((m) => {
this[m] = this[m].bind(this)
});
}
}
}
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
const { computed, get, set } = Ember;
/* To replicate issue:
ASDF1
ASDF1__
ASDF1___
@mikemunsie
mikemunsie / secrets.md
Last active February 12, 2018 20:56
ember-secrets

Renaming attributes in a serializer:

export default DS.JSONAPISerializer.extend({
 attrs: { results: 'data' }
});

Customizing the key in a list '@identity', '@index', or your own:

@mikemunsie
mikemunsie / rules.js
Created January 4, 2018 19:44
Find Stylesheet Classes
// Make one massive array of all the rules from the stylesheets on the page
const styleSheetRules = Object.keys(document.styleSheets).reduce((rules, i) => {
const styleRules = document.styleSheets[i].cssRules || [];
Object.keys(styleRules).forEach((j) => {
rules.push(styleRules[j]);
});
return rules;
}, []);
// Function used to lookup the rules from the stylesheet
@mikemunsie
mikemunsie / components.my-component.js
Created October 13, 2017 20:54
Can Ember Nested Routes Do This?
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
alert('yep');
}
});
@mikemunsie
mikemunsie / phoneMasks.json
Last active April 25, 2024 08:37
Phone Masks by Country Code JSON
{
"AC": "+247-####",
"AD": "+376-###-###",
"AE": "+971-5#-###-####",
"AE": "+971-#-###-####",
"AF": "+93-##-###-####",
"AG": "+1(268)###-####",
"AI": "+1(264)###-####",
"AL": "+355(###)###-###",
"AM": "+374-##-###-###",
@mikemunsie
mikemunsie / components.test-component.js
Created September 11, 2017 14:59
Computed Default Attrs
import Ember from 'ember';
const {
computed,
get
} = Ember;
export default Ember.Component.extend({
name: computed('name', function() {
console.log('here');