Skip to content

Instantly share code, notes, and snippets.

View foxel's full-sized avatar
🇦🇲

Andrey Kupreychik foxel

🇦🇲
View GitHub Profile
@foxel
foxel / midpass.js
Created February 27, 2023 15:33 — forked from bushaev-denis/midpass.js
Midpass calendar notify has available record
const beep = (date) => {
const context = new AudioContext();
const oscillator = context.createOscillator();
oscillator.type = "sawtooth";
oscillator.frequency.value = 1200;
oscillator.connect(context.destination);
oscillator.start();
if (confirm("Появилась запись")) {
oscillator.stop();
document.location.href = 'https://q.midpass.ru/ru/Booking/Date?serviceId=54030d6a-e145-08e2-60fb-33344fac2455&date=' + date;
@foxel
foxel / backup-to-Glacier.sh
Last active December 2, 2021 07:37 — forked from macbookandrew/backup-to-Glacier.sh
Ubuntu incremental encrypted backups to S3/Glacier
#!/bin/bash
#
# Note, to pull a file from s3 use "s3cmd get s://bucket/file destinationfile"
# You must have the proper .s3cfg file in place to decrypt the file.
# You may also use "gpg encryptedfile" and supply the encryption code if you download
# from the web interface. Good luck.
# The bucket should be set to transfer to Glacier. To retreive, you need to initiate a
@foxel
foxel / deep_keys.type.ts
Last active March 2, 2021 07:37
TypeScript 4.1 deep keys extraction type.
// TypeScript 4.1 deep keys extraction type
// combination of https://flut1.medium.com/deep-flatten-typescript-types-with-finite-recursion-cb79233d93ca
// and https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#key-remapping-in-mapped-types
type KeysPrependRecursor<T, P extends string> = {
[K in keyof T as `${P}.${string & K}`]: T[K] extends Object ? KeysPrependRecursor<T[K], `${P}.${string & K}`> : T[K]
}
type KeysPrepend<T> = {
[K in keyof T]: T[K] extends Object ? KeysPrependRecursor<T[K], `${string & K}`> : T[K]
}
@foxel
foxel / configuration.yaml
Last active January 27, 2021 11:33
HA custom component for controlling Keenetic 3G internet link with ZTE MF833 modem
switch:
- platform: modem_control
name: Megafon Internet
host: !secret router_ip
username: !secret router_username
password: !secret router_password
@foxel
foxel / VaryTempWithHeight.py
Created October 31, 2018 15:18
Cura 3 VaryTempWithHeight post processing script for temp towers.
# -*- coding: utf-8 -*-
import json
import re
from ..Script import Script
class VaryTempWithHeight(Script):
def __init__(self):
@foxel
foxel / VaryTempWithHeight.py
Created October 31, 2018 15:17
Cura 3 VaryTempWithHeight post processing script for temp towers.
# -*- coding: utf-8 -*-
import json
import re
from ..Script import Script
class VaryTempWithHeight(Script):
def __init__(self):
#!/usr/bin/python2.7
import sys
# assuming you have https://github.com/foxel/noolite-mqtt-python near
from noolite_serial import NooLiteSerial
noo_serial = NooLiteSerial('/dev/ttyS0')
if len(sys.argv) < 3:
raise Exception('Not Enough params. Usage: noo.py [ch] [cmd]')
{
"definitions": {
"CreateDocumentCommand": {
"type": "object",
"required": ["eventType", "documentName"],
"properties": {
"eventType": {
"type": "string",
"enum": ["CreateDocument"]
},
@foxel
foxel / reactive-loader.ts
Created March 2, 2018 06:48
Reactive loader with guarantee of no load collisions and loading status provided.
import { Observable } from 'rxjs/Observable';
import { Subscription } from 'rxjs/Subscription';
import { Subject } from 'rxjs/Subject';
import 'rxjs/add/operator/switchMap';
export class ReactiveLoader<T, T1> {
private _requestQueue: Subject<T1>;
private _resultQueue: Observable<T>;
private _loaded: boolean = false;
@foxel
foxel / Chief_n_Pizza.ts
Created September 29, 2017 08:45
Phantom Builder in TS
// Inspired by https://medium.com/@maximilianofelice/builder-pattern-in-scala-with-phantom-types-3e29a167e863
export type Pizza = {};
namespace Pizza {
export type WithCheese = {
readonly cheese: string;
};
export type WithTopping = {
readonly topping: string;