Skip to content

Instantly share code, notes, and snippets.

View benqus's full-sized avatar
🎯
Focusing

Bence Kormos benqus

🎯
Focusing
  • London, United Kingdom
View GitHub Profile
@benqus
benqus / counter-component.tsx
Created February 20, 2024 23:39
Why TF is this not working ...
import { JSX } from 'solid-js';
import { CounterContextProvider, useCounterContext } from '../contexts/counter';
export function WithContext(): JSX.Element {
const [ { count }, { increment, decrement } ] = useCounterContext();
return (
<CounterContextProvider>
<span>{count}</span>
<button onClick={increment}>+</button>
@benqus
benqus / pubsub.js
Last active August 12, 2021 07:48
export class PubSub {
constructor() {
this._subs = new Map()
}
subscribe(action, fn) {
if (!this._subs.has(action)) {
this._subs.set(action, new Set())
}
/**
* @class
* @classdesc The Job model class
*/
var Job = Model.extend({
idAttribute: 'resource_uri',
defaults: {
name: 'n/a'
@benqus
benqus / Sibling.js
Created November 11, 2014 15:47
Simple Mediator
function Sibling() {
mediator.add(this);
this.id = Sibling.getUniqueID();
}
Sibling.getUniqueID = (function () {
var id = 0;
return function () {
return id++;
@benqus
benqus / Observable.js
Last active August 29, 2015 14:09
Observable - Pub/Sub
/**
* Provides basic Pub/Sub interface and functionality
*
* @class Observable
*/
function Observable() {
this.subscribers = [];
}
/**
@benqus
benqus / fjs
Last active August 29, 2015 14:05
fjs - idea
http://pastebin.com/zKpJY9ck - copy from there
# single line comment
##
multi line comment
##
# variable assignment
a = 7.
// Backbone.js 2.0.0
// (c) 2010-2011 Jeremy Ashkenas, DocumentCloud Inc.
// (c) 2011-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Backbone may be freely distributed under the MIT license.
// For all details and documentation:
// http://backbonejs.org
(function () {
@benqus
benqus / js_inheritance
Created January 8, 2013 12:20
JavaScript inheritance behaviour testing
var prototypeTest = (function () {
/**
* Instance class definition
* inherits from Base
*/
function Instance() {
//super class constructor
Base.apply(this, arguments);
}
@benqus
benqus / UIElement
Last active October 10, 2015 12:38
[Experimental] Class that binds together a JavaScript object with a HTMLElement [ECMAScript5]
/**
* UIElement class
* @param [tagName] {String} the nodeName of the HTMLElement to bind to
* @param [ctx] {Function} this function will be called to decorate the new instance
*/
var UIElement = function (arg, ctx) {
var element,
context;
//only one argument given