Skip to content

Instantly share code, notes, and snippets.

View abulka's full-sized avatar
🤔
Prototyping an online, low code IDE

Andy Bulka abulka

🤔
Prototyping an online, low code IDE
View GitHub Profile
@abulka
abulka / todomvc-oo-config.js
Last active May 16, 2020 05:33
TodoMVC-OO - config
let config = {
// Callback to create the todo item controllers - are added as needed
cb_todo: function (app, todo) {
new ControllerTodoItem(
app,
todo,
{ $todolist: $('ul.todo-list') }
)
},
@abulka
abulka / todomvc-oo-bootstrap.js
Last active May 16, 2020 05:34
TodoMVC-OO - Bootstrap
(function (window) {
let config = {...}
new Application(config)
})(window);
@abulka
abulka / todomvc-oo-application-model.js
Last active May 16, 2020 05:34
TodoMVC-OO - Application model
class Application {
constructor(config) {
this.todos = [] // model collection
this.filter = 'all' // view model, options are: 'all', 'active', 'completed'
...
}
@abulka
abulka / todomvc-oo-models.js
Last active May 16, 2020 05:34
TodoMVC-OO - TodoItem model
class TodoItem {
constructor(title, id, completed) {
this._title = title == undefined ? "" : title;
this._completed = completed == undefined ? false : completed;
this.id = id == undefined ? util.uuid() : id; // no getter/setter needed
}
get title() {
return this._title;
}
@abulka
abulka / CSharpLexer.py
Created December 23, 2019 04:46
CSharpLexer.py incl repairs to convert Java code into Python
# Generated from CSharpLexer.g4 by ANTLR 4.7.2
from antlr4 import *
from io import StringIO
from typing.io import TextIO
import sys
# import java.util.Stack;
def serializedATN():
@abulka
abulka / sm_example1.plantuml
Last active July 20, 2019 08:19
Software Map Example 01
class Compact {
.. def <u><b>fred() ..
<i>Mainly responsible for this and that
<i>Calls GetShapeList() to get all the shapes
+ for shape in self.GetDiagram().<b>GetShapeList()</b>: <u>1
<i>Then process this and that calling the parent
+ if shape.<b>GetParent()</b> == None: <u>2
@abulka
abulka / observer_oo.py
Created July 17, 2019 01:38
Observer design pattern for Python
class Observer:
def __init__(self):
self.subject = None
def Notify(self, target, data):
if target:
print(f" Observer {self.__class__} got notification from: {target.__class__}, data: '{data}'")
else:
print(f"Observer {self.__class__} got direct call to notify(), data: '{data}'")
@abulka
abulka / dirty_observer_fragment.py
Created July 16, 2019 07:59
Alternative to the Observer pattern for ECS systems
do = DirtyObserver(world)
do.add_dependency(ModelRef, [entity_welcome_left, entity_edit_welcome_msg, entity_edit_user_name_msg, entity_edit_user_surname_msg])
do.add_dependency(MultiModelRef, [entity_welcome_user_right])
do.add_dependency("welcome display only, not via model", [entity_welcome_left, entity_welcome_user_right])
do.add_dependency("user display only, not via model", [entity_welcome_user_right])
do.add_dependency("just top right", [entity_welcome_user_right])
@abulka
abulka / dirty_observer_fragment.py
Created July 16, 2019 07:59
Alternative to the Observer pattern for ECS systems
do = DirtyObserver(world)
do.add_dependency(ModelRef, [entity_welcome_left, entity_edit_welcome_msg, entity_edit_user_name_msg, entity_edit_user_surname_msg])
do.add_dependency(MultiModelRef, [entity_welcome_user_right])
do.add_dependency("welcome display only, not via model", [entity_welcome_left, entity_welcome_user_right])
do.add_dependency("user display only, not via model", [entity_welcome_user_right])
do.add_dependency("just top right", [entity_welcome_user_right])
@abulka
abulka / main_ecs_fragment_gui_event_handlers.js
Last active July 16, 2019 07:31
What gui event handlers do in my ECS architecture
//
// GUI events
//
$('#change_welcome_model').on('click', function(e) {
model.welcomemsg = isUpperCaseAt(model.welcomemsg, 1) ? model.welcomemsg.toLowerCase() : model.welcomemsg.toUpperCase()
world.tick()
})
$('#change_user_model').on('click', function(e) {