Skip to content

Instantly share code, notes, and snippets.

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

Matias Trujillo UpperCod

🏠
Working from home
View GitHub Profile
@UpperCod
UpperCod / javascript
Created October 4, 2018 17:27
Sample import atomico
import { h, Element } from "atomico";
customElements.define(
"atom-hello",
class extends Element {
static get props() {
return ["text"];
}
render() {
return <h1>hello {this.props.text}</h1>;
}
@UpperCod
UpperCod / bash
Created April 12, 2019 00:14
Error npm run build:native
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build:native' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild:native', 'build:native', 'postbuild:native' ]
5 info lifecycle [email protected]~prebuild:native: [email protected]
6 info lifecycle [email protected]~build:native: [email protected]
WebComponent.props = {
fieldName: {
type: String,
value: "Default value"
}
};
function createEventEmmiter() {
let events = new Map();
function addEventListener(type, callback) {
if (!events.has(type)) {
events.set(type, new Map());
}
events.get(type).set(callback);
}
export const Any = null;
export class BaseElement extends HTMLElement {
constructor() {
super();
this.setup();
}
async setup() {
this._attrs = {};
this._props = {};
@UpperCod
UpperCod / test.js
Created June 17, 2020 14:00
reduce, for of, for length
/**
* test peflink
* {@link https://perf.link/#eyJpZCI6IjYxcTQzOXdrd2J5IiwidGl0bGUiOiJGaW5kaW5nIG51bWJlcnMgaW4gYW4gYXJyYXkgb2YgMTAwMCIsImJlZm9yZSI6ImNvbnN0IGRhdGEgPSBbLi4uQXJyYXkoMTAwMCkua2V5cygpXS5tYXAoKHByb3ApID0%2BICh7XG4gIHByb3AsXG4gIHZhbHVlOiBNYXRoLnJhbmRvbSgpLFxufSkpOyIsInRlc3RzIjpbeyJuYW1lIjoiVHJhbnNmb3JtIGEgbWFwIG9mIHByb3BzIGFuZCB2YWx1ZXMgdG8gYW4gb2JqZWN0IHVzaW5nIHJlZHVjZSIsImNvZGUiOiJjb25zdCBuZXh0RGF0YSA9IGRhdGEucmVkdWNlKChuZXh0RGF0YSwgeyBwcm9wLCB2YWx1ZSB9KSA9PiB7XG4gIG5leHREYXRhW3Byb3BdID0gdmFsdWU7XG4gIHJldHVybiBuZXh0RGF0YTtcbn0sIHt9KTsiLCJydW5zIjpbNDgzMyw1NjY2LDU2NjYsODUwMCw1MTY2LDU1MDAsNjE2Niw1NjY2LDkzMzMsNjE2Niw1MDAwLDU2NjYsNjAwMCw1NjY2LDQ2NjYsNTgzMyw4NjY2LDYxNjYsNjMzMyw3MzMzLDU2NjYsNTY2NiwxMTUwMCw2MzMzLDcwMDAsNDY2Niw1NjY2LDExMDAwLDcwMDAsOTAwMCw1NTAwLDU2NjYsODE2Niw1NjY2LDY4MzMsNTY2Niw5MzMzLDQwMDAsNTY2Niw2NTAwLDc2NjYsNDgzMyw1MTY2LDExNTAwLDU4MzMsNTY2NiwxMDY2Niw3MzMzLDU2NjYsNTY2Niw1NjY2LDg4MzMsODgzMyw1NjY2LDY1MDAsNTAwMCw3MTY2LDk2NjYsNDE2Niw4MTY2LDU2NjYsNTY2Niw4MTY2LDQxNjYsNTY2Niw3MDAwLDU2NjYsOTUwMCw
@UpperCod
UpperCod / concurrent-task-optimization.js
Created July 16, 2020 19:08
Small script to optimize concurrency in browsers, ideal for handling concurrent animations between 55fps to 60fps
let task = [];
let inLoop;
let loopTask = () => {
let currentTask = task;
task = [];
let fn;
let start = performance.now();
while ((fn = currentTask.pop())) {
let now = performance.now();
@UpperCod
UpperCod / file.css
Last active September 8, 2020 22:58
.body{color:tomato}
.button{color:black}
@UpperCod
UpperCod / get-block-css.ts
Created October 4, 2020 15:54
capture the css blocks, great to use with sheet.insertRule
const add = (list: string[]) => (rule: string) => list.push(rule) && "";
function parse(css: string) {
const rules = [];
const atRules = [];
css
.replace(/\s+/g, " ")
.replace(/@([^{]+)\{(.*?}) *}/g, add(atRules))
.replace(/([^}{;]*){([^}{]+)}/g, add(rules));
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.