Skip to content

Instantly share code, notes, and snippets.

@blikblum
blikblum / example
Created July 5, 2022 03:46
json schema faker allOf
{
"type": "object",
"properties": {
"collection": {
"type": "array",
"items": {
"allOf": [
{
"$ref": "#/definitions/model"
}
@blikblum
blikblum / Markdium-JavaScript.js
Created February 3, 2020 23:12
Markdium-From React to Web Components: using hooks (part 2)
module.exports = {
resolve: {
alias: {
react: 'haunted'
}
}
}
@blikblum
blikblum / Markdium-JavaScript.js
Created February 3, 2020 22:55
Markdium-From React to Web Components: using hooks
const ref = directive((refInstance) => (part) => {
if (!(part instanceof AttributePart)) {
throw new Error('ref directive can only be used as an attribute');
}
refInstance.current = part.committer.element;
});
@blikblum
blikblum / Markdium-JavaScript.js
Created February 3, 2020 22:55
Markdium-From React to Web Components: using hooks
useEffect(() => {
const handleNewMessages = snap => {
// avoid updating messages when there are no changes
const changes = snap.docChanges()
if (changes.length) {
setMessages(snap.docs.map(doc => doc.data()))
}
}
const unsubscribe = chatRoomMessages.onSnapshot(handleNewMessages);
return unsubscribe;
@blikblum
blikblum / Markdium-JavaScript.js
Created February 3, 2020 22:55
Markdium-From React to Web Components: using hooks
const messagesRef = useRef();
useEffect(() => {
if (messagesRef.current) {
messagesRef.current.scrollTop = messagesRef.current.scrollHeight;
}
}, [messages]);
@blikblum
blikblum / search-tests.js
Created July 1, 2019 11:41
Unit test select2 dropdown close
test('click on input opens but do not closes the dropdown', function (assert) {
var $container = $('#qunit-fixture .event-container');
var container = new MockContainer();
var CustomSelection = Utils.Decorate(MultipleSelection, InlineSearch);
var $element = $('#qunit-fixture .multiple');
var selection = new CustomSelection($element, options);
var $selection = selection.render();
@blikblum
blikblum / event.js
Last active November 28, 2019 01:31
Decorator implementations
// helper function
const registerDelegatedEvent = (ctor, eventName, selector, listener) => {
const classEvents = ctor.__events || (ctor.__events = []);
classEvents.push({ eventName, selector, listener });
};
// old dynamic spec
const event = (eventName, selector) => (protoOrDescriptor, methodName, propertyDescriptor) => {
if (typeof methodName !== 'string') {
const { kind, key, placement, descriptor, initializer } = protoOrDescriptor;
@blikblum
blikblum / modules.json
Last active December 9, 2018 13:52
lodash-modules-statistics
[
{
"name": "add",
"size": 5918,
"ownSize": 350,
"ownPercent": 5.91,
"dependencies": [
{
"name": "getTag",
"size": 1579,
@blikblum
blikblum / home-template.html
Last active September 22, 2017 12:31
Marionette F7 Demo - Home page
<div class="page-content">
<div class="content-block-title">Welcome</div>
<div class="content-block">
<p>Enjoy using Backbone/Marionette with the awesome Framework7!</p>
</div>
<div class="content-block-title">Examples</div>
<div class="list-block">
<ul>
<li class="item-content">
import {createApp, showView} from 'marionette.f7'
import HomeView from './home/view'
import Tab2View from './tab2/view'
createApp({
options: {
material: false
},
views: {