Skip to content

Instantly share code, notes, and snippets.

View MartinMuzatko's full-sized avatar
🐈

Martin Muzatko MartinMuzatko

🐈
View GitHub Profile
import './style.css'
import { createDrawFunction, objectTypes } from 'declarative-canvas'
interface Point {
x: number
y: number
}
interface Player extends Point {
width: number
import { BlitzApiHandler, BlitzApiRequest, BlitzApiResponse, getSession } from 'blitz'
import multer from 'multer'
import * as path from 'path'
import * as fs from 'fs/promises'
import db from 'db'
import cors from 'cors'
import { nanoid } from 'nanoid'
const runMiddleware = (req: BlitzApiRequest, res: BlitzApiResponse, fn: (req, res, fn) => any) =>
new Promise((resolve, reject) => {
{"openapi":"3.0.1","info":{"title":"SICON Gateway REST API","version":"1.0.0","description":"This API provides access to the gateway database and its adapters, devices and spawned errors."},"host":"a","servers":[{"url":"/api/v1"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"security":[{"bearerAuth":[]}],"swagger":"2.0","paths":{"/app-catalog":{"get":{"security":[{"bearerAuth":[]}],"tags":["appCatalog"],"description":"Serves a list of apps from the catalog","produces":["application/json"],"responses":{"200":{"description":"OK"},"401":{"description":"Authorization failed"}}}},"/apps":{"get":{"tags":["app"],"security":[{"bearerAuth":[]}],"description":"Serves a list of installed apps plus the default one","produces":["application/json"],"responses":{"200":{"description":"OK"},"401":{"description":"Authorization failed"}}},"post":{"security":[{"bearerAuth":[]}],"description":"Triggers the installation of a new app","tags":["app"],"produces":["application
<html>
<head>
<!-- Site optimized with MySEO 1.0 -->
{$seo_index}
<!-- Site optimized with MySEO 1.0 -->
<title>{$mybb->settings['bbname']}</title>
<meta http-equiv=“Pragma” content=”no-cache”>
<meta http-equiv=“Expires” content=”-1″>
import * as fs from 'fs/promises'
interface Habit {
name: string
process: string[]
}
interface HabitsPageDependencies {
load: (amount: number) => Promise<Habit[]>
}
Zigbee2MQTT:debug 2021-02-02 21:56:42: Loaded state from file /app/data/state.json
Zigbee2MQTT:info 2021-02-02 21:56:42: Logging to console and directory: '/app/data/log/2021-02-02.21-56-41' filename: log.txt
Zigbee2MQTT:info 2021-02-02 21:56:42: Starting Zigbee2MQTT version 1.17.0-dev (commit #2ef2c54)
Zigbee2MQTT:info 2021-02-02 21:56:42: Starting zigbee-herdsman (0.13.57)
Zigbee2MQTT:debug 2021-02-02 21:56:42: Using zigbee-herdsman with settings: '{"adapter":{"concurrent":null,"delay":null},"backupPath":"/app/data/coordinator_backup.json","databaseBackupPath":"/app/data/database.db.backup","databasePath":"/app/data/database.db","network":{"channelList":[11],"extendedPanID":[221,221,221,221,221,221,221,221],"networkKey":"HIDDEN","panID":4000},"serialPort":{"path":"/dev/ttyUSB0"}}'
Zigbee2MQTT:info 2021-02-02 21:56:46: zigbee-herdsman started
Zigbee2MQTT:info 2021-02-02 21:56:46: Coordinator firmware version: '{"meta":{"maintrel":1,"majorrel":2,"minorrel":7,"product":1,"revision":20200715,"transpo
@MartinMuzatko
MartinMuzatko / di.js
Last active October 8, 2020 12:31
Different types of Dependency Injection in JavaScript
// Dependency Injection
// single dep
const random = Math => Math.random()
random({ random: () => 4 }) // 4
random(Math) // anything between 0 - 1
// multiple deps - as parameters
const WIN = 1
const LOSE = -1
const TIE = 0
const methods = ['rock', 'paper', 'scissor']
let score = 0
const gameMap = new Map([
['rock-paper', LOSE],
['rock-scissor', WIN],
const meow = require('meow')
const prop = k => o => o[k]
const pipe = (...fns) => x => [...fns].reduce((acc, f) => f(acc), x)
const siconstore = () => ({
cli: meow(`
Usage
$ siconstore [command]
Available Commands
const createAppsConfig = configFiles => ({
...configFiles,
config: configFiles.appInstances,
list: partial(list, [configFiles]),
get: partial(get, [configFiles]),
create: partial(create, [configFiles]),
edit: partial(edit, [configFiles]),
remove: partial(remove, [configFiles]),
update: partial(update, [configFiles]),
initApps: partial(initApps, [configFiles]),