Skip to content

Instantly share code, notes, and snippets.

View betocantu93's full-sized avatar
🏠
Working from home

Alberto Cantú Gómez betocantu93

🏠
Working from home
View GitHub Profile
@betocantu93
betocantu93 / superhash.js
Created March 10, 2021 21:37
SuperHash PoC
function set(target, name, value) {
const attrConfig = target.constructor?.attributes[name];
if (typeof attrConfig?.init === 'function') {
target[name] = attrConfig.init.call(this, value);
}
if (attrConfig?.defaultValue) {
target[name] = attrConfig.defaultValue;
} else if (typeof attrConfig?.transform === 'function') {
target[name] = attrConfig.transform.call(target, value);
} else {
@betocantu93
betocantu93 / machine.js
Last active January 13, 2021 16:44
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@betocantu93
betocantu93 / machine.js
Created October 20, 2020 16:14
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@betocantu93
betocantu93 / machine.js
Last active September 18, 2020 16:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@betocantu93
betocantu93 / app-shell.js
Created September 17, 2020 18:15
Clean the dom when ember root view is ready
export function initialize(appInstance) {
if (typeof FastBoot === 'undefined') {
let originalDidCreateRootView = appInstance.didCreateRootView;
appInstance.didCreateRootView = function() {
let elements = document.querySelectorAll(appInstance.rootElement + ' #app-shell');
for (let i = 0; i < elements.length; i++) {
let element = elements[i];
element.parentNode.removeChild(element);
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
}
@betocantu93
betocantu93 / globals.js
Last active June 22, 2020 20:03
Adds some runtime globals for making Ember.js developing a breeze
//instance-initializers/globals.js
export function initialize(application) {
let { environment } = application.resolveRegistration('config:environment');
if (environment !== "production") {
/**
This basically exposes the application, pretty useful because
you can use stuff like this from the console.
import Mixin from '@ember/object/mixin';
import Ember from 'ember';
import { singularize } from 'ember-inflector';
export default Mixin.create({
// ember temporary ids
_tempIds: {},
@betocantu93
betocantu93 / dynamic-model-initializers-model.js
Last active April 7, 2020 23:40
Reopen models in runtime
import DS from "ember-data";
import { computed } from "@ember/object";
import { assert } from "@ember/debug";
const { Model } = DS;
Model.reopenClass({
/**
* The following props are overrided, since per definition
* they are sealed props defined in
{
"basics": {
"name": "Alberto Cantú Gómez",
"label": "CEO",
"picture": "",
"email": "betocantu93@gmail.com",
"phone": "+52 8125671871",
"website": "https://betocantu93.com",
"summary": "Software engineer as profession, passionate digital entrepreneur and investor, working everyday building teams and businesses from scratch and pushing them forward.",
"location": {