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 / Scroll To Bottom.ipynb
Last active February 17, 2022 03:03
Scroll To Bottom.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@abulka
abulka / main.dart
Created July 19, 2021 03:46
My SO answer to replicating an android layout
import 'package:flutter/material.dart';
// My answer to
// https://stackoverflow.com/questions/61443845/how-to-replicate-this-specific-android-constraint-layout-on-flutter
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@abulka
abulka / fncache.py
Last active April 24, 2024 11:03 — forked from kwarrick/fncache.py
Redis-backed LRU cache decorator in Python.
#!/usr/bin/env python
__author__ = 'Kevin Warrick'
__email__ = '[email protected], [email protected]'
__version__ = '2.0.0'
import pickle
from collections import namedtuple
from functools import wraps
import inspect
from icecream import ic
@abulka
abulka / dedent.dart
Last active July 16, 2020 13:09
Dart dedent() function inspired by Python dedent
library dedent;
// Translation of Python textwrap.dedent algorithm
// https://github.com/python/cpython/blob/eb97b9211e7c99841d6cae8c63893b3525d5a401/Lib/textwrap.py
import 'package:quiver/iterables.dart';
String dedent(String text) {
/// Remove any common leading whitespace from every line in `text`.
/// This can be used to make triple-quoted strings line up with the left
@abulka
abulka / todomvc-ecs-flags.js
Created May 18, 2020 01:51
TodoMVC-ECS Flags
e.setComponent('Flag', {})
e.setComponent('Flag2', null)
@abulka
abulka / todomvc-ecs-optimising2.js
Created May 17, 2020 11:51
TodoMVC-ECS Optimising2
entity.getComponent('data').completed = false
entity.setComponent('dirty', {})
@abulka
abulka / todomvc-ecs-optimising.js
Last active May 17, 2020 11:49
TodoMVC-ECS Optimising
engine.system('dirty-todoitems', ['data', 'dirty'], (entity, {data, _}) => {
// do something with entity and data
// ...
entity.deleteComponent('dirty') // important! remove dirty flag
}
@abulka
abulka / todomvc-ecs-persistence.js
Created May 17, 2020 11:48
TodoMVC-ECS Persistence
class Persistence {
constructor() {
this.todos_data = [] // gather info here
engine.system('reset-save', ['housekeeping'], (entity, { _ }) => {
this.todos_data = []
});
engine.system('gather-todos-for-save', ['data'], (entity, { data }) => {
this.todos_data.push(data)
@abulka
abulka / todomvc-ecs-gathering-todos.js
Created May 17, 2020 11:47
TodoMVC-ECS Gathering Todos
let todos_data = []
engine.system('reset-todo-list', ['housekeeping'], (entity, { housekeeping }) => {
todos_data = []
});
engine.system('gather-todos-for-save', ['data'], (entity, { data }) => {
todos_data.push(data) // or push data.title, or push the entity, or whatever you need
});
engine.system('report-final-result', ['housekeeping'], (entity, { housekeeping }) => {
console.log('final list of todos', todos_data)
@abulka
abulka / todomvc-ecs-housekeeping2.js
Created May 17, 2020 11:46
TodoMVC-ECS Housekeeping Trick Part 2
engine.system('reset-todos', ['housekeeping'], (entity, { _ }) => {
this.todos = []
})