Skip to content

Instantly share code, notes, and snippets.

View stalniy's full-sized avatar
🏠
Working from home

Sergii Stotskyi stalniy

🏠
Working from home
View GitHub Profile
@stalniy
stalniy / 1. Intro.md
Last active October 19, 2024 11:48
Ebusd Vaillant Eloblock

Прошивка Wemos D1 mini для ebusd адаптера

Зазначені нижче кроки будуть актуальні для linux (ubuntu) та macos, вінда на "відпочинку" не мав змоги перевірити це там. Для прошивки будемо використовувати esptool.py

Вимоги: ubuntu : встановлений пайтон 3.8.10, або вище (має бути доступний за замовчанням, перевіряємо: python3 -V) macos : встановлений brew, за допомогою якого доставимо все необхідне

Установка esptool: MacOS:

@stalniy
stalniy / example.js
Created October 16, 2020 19:01
UCAST dot notation
const test = guard({ 'author.id': 1 });
const sifter = sift({ 'author.id': 1 });
console.log(test({ author: { id: 1 } })) // true
console.log(sifter({ author: { id: 1 } })) // true
@stalniy
stalniy / example.js
Created October 16, 2020 18:58
ucast and sift.js difference
import { guard } from '@ucast/mongo2js';
import sift from 'sift';
const test = guard({ author: { id: 1 } });
const sifter = sift({ author: { id: 1 } });
console.log(test({ author: { id: 1 } })) // false
console.log(sifter({ author: { id: 1 } })) // true
@stalniy
stalniy / example.js
Created October 16, 2020 18:56
MongoDB query parser + JS interpreter
import { MongoQueryParser, allParsingInstructions } from '@ucast/mongo';
import { createJsInterpreter, allInterpreters } from '@ucast/js';
const parser = new MongoQueryParser(allParsingInstructions);
const interpret = createJsInterpreter(allInterpreters);
const ast = parser.parse({ authorId: 1, status: 'published' });
console.log(interpret(ast, { authorId: 1, status: 'published' })); // true
console.log(interpret(ast, { authorId: 2, status: 'published' })); // false
@stalniy
stalniy / example.js
Created October 16, 2020 18:55
JavaScript UCAST Interpreter
import { createJsInterpreter, eq, lt, gt } from '@ucast/js';
const interpret = createJsInterpreter({ eq, lt, gt });
@stalniy
stalniy / example.js
Created October 16, 2020 18:54
MongoDB Query parser
import { MongoQueryParser, $eq } from '@ucast/mongo';
const parser = new MongoQueryParser({ $eq });
const ast = parser.parse({
authorId: 1
});
@stalniy
stalniy / index.js
Created August 10, 2020 12:52
CASL + Objection
const { defineAbility } = require('@casl/ability');
const { rulesToQuery } = require('@casl/ability/extra');
const Knex = require('knex');
const { Model } = require('objection');
const { interpret } = require('@ucast/objection')
const { CompoundCondition } = require('@ucast/core')
const knex = Knex({
client: 'sqlite3',
connection: ':memory:'
@stalniy
stalniy / sjQuery.class.php
Last active July 29, 2020 07:46
Extended Doctrine 1.2 Query class with support for multiInsert
<?php
class sjQuery extends Doctrine_Query {
protected
$_insert_queue_size = 0,
$_insert_queue = array(),
$_last_insert_ids = array(),
$_relations_queue = array();
public function queueSize(){
return count($this->_insert_queue);
@stalniy
stalniy / sequelize.ts
Created July 8, 2020 09:30
UCAST sequelize
import { createInterpreter, InterpretationContext, Condition, FieldCondition, Comparable, CompoundCondition } from '@ucast/core'
import { MongoQueryParser, allParsingInstructions } from '@ucast/mongo';
import sequelize from 'sequelize';
const seq = new sequelize.Sequelize('sqlite::memory:');
class User extends sequelize.Model {}
User.init({
firstName: {
@stalniy
stalniy / ability.js
Created April 10, 2020 12:56
CASL 4.0 subject type detection for POJO
import { defineAbility, subject as an } from '@casl/ability';
const object = {
title: 'My article',
description: '...',
};
ability.can('read', an('Article', object));
// or