Skip to content

Instantly share code, notes, and snippets.

@vospascal
vospascal / Group.model.ts
Last active July 11, 2024 13:31
lit + signals
import { Signal, signal } from "@preact/signals-core";
import DetailModel from '../detail/Detail.model.ts';
import SubscriptionService from "../services/SubscriptionService";
class GroupModel {
#type: Signal<string> = signal('GROUP');
#id: Signal<string> = signal('');
#path: Signal<string> = signal('');
#name: Signal<string> = signal('');
#items: Signal<Array<DetailModel | GroupModel>> = signal([]);
@vospascal
vospascal / ChromeDevToolsTimlineEvents.js
Created August 9, 2023 21:19
ChromeDevTools timeline events
// https://github.com/ChromeDevTools/devtools-frontend/blob/1061a013745d1f638b1f989204886232fd5a835a/front_end/panels/timeline/TimelineUIUtils.ts
// https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
// as info https://github.com/GoogleChrome/lighthouse/blob/7ae8bd442d83efcca1cb48c5c48302d974b00756/core/lib/tracehouse/task-groups.js#L26
export const taskGroups = {
painting: {
id: 'painting',
label: 'Painting',
traceEventNames: [
"PaintSetup",
"Paint",
@vospascal
vospascal / context_dynamic_scope.js
Created November 2, 2021 17:34
context provider
import React from "react";
const Name = React.createContext("Default");
const Greet = () => {
const name = React.useContext(Name);
return <p>Hello {name}</p>;
};
export default function App() {
/*!
* ExternalTemplateRemotesPlugin
* License: MIT (https://mit-license.org/)
*/
const extractUrlAndGlobal = require('webpack/lib/util/extractUrlAndGlobal');
const { RawSource } = require('webpack-sources');
const PLUGIN_NAME = 'ExternalTemplateRemotesPlugin';
@vospascal
vospascal / HOC.js
Created June 29, 2019 14:14 — forked from Restuta/HOC.js
React HOC (Higher Order Component) Example
/* HOC fundamentally is just a function that accepts a Component and returns a Component:
(component) => {return componentOnSteroids; } or just component => componentOnSteroids;
Let's assume we want to wrap our components in another component that is used for debugging purposes,
it just wraps them in a DIV with "debug class on it".
Below ComponentToDebug is a React component.
*/
//HOC using Class
//it's a function that accepts ComponentToDebug and implicitly returns a Class
let DebugComponent = ComponentToDebug => class extends Component {