Skip to content

Instantly share code, notes, and snippets.

@hectorlorenzo
hectorlorenzo / aocd3.js
Created December 4, 2017 14:47
Solution to Advent of Code 3
function sum (x) {
var sum = 0;
while(x > 0) {
sum = sum + x;
x--;
}
return sum;
}
@hectorlorenzo
hectorlorenzo / aocd1.js
Created December 1, 2017 17:58
Advent of code day 1
function sumConsecutive (number) {
var arrayOfNumbers = number.split('')
var sum = 0
var currentNumber = null
var nextNumber = null
var arrayLength = arrayOfNumbers.length
for (var i = arrayLength - 1; i >= 0; i--) {
currentNumber = arrayOfNumbers[i]
const elemClass = class extends HTMLElement {
constructor() {
super()
}
static get observedAttributes () {
return Object.keys(this.options.data)
}
}
const elemClass = class extends HTMLElement {
constructor() {
super()
}
attributeChangedCallback (name, oldValue, newValue) {
const o = this
const options = o.options
options.watch[name].call(o, oldValue, newValue)
}
const elemClass = class extends HTMLElement {
constructor() {
super()
}
connectedCallback () {
const o = this
const data = o.options.data
Object.keys(data).forEach((key) => {
Object.defineProperty(o, key, {
const customHeading = document.createElement('custom-heading')
document.body.appendChild(customHeading)
Vue.component('my-component', {
template: '<div>A custom component!</div>'
})
class CustomHeading extends HTMLElement {
constructor () {}
}
customElements.define('custom-heading', CustomHeading)
@hectorlorenzo
hectorlorenzo / Main.md
Last active November 13, 2020 11:09
Learning React when coming from Vue

Learning React the Vue way

componentDidMount

Part of the component lifecycle, similar to created/mounted.

componentWillUnmount

Part of the component lifecycle, similar to destroyed

import initMixin from './internal/init'
/* ... */
function Vue (options) {
this._init(options)
}
/* ... */