Skip to content

Instantly share code, notes, and snippets.

View ovcharik's full-sized avatar

Maksim Ovcharik ovcharik

  • Saint Petersburg, Russia
View GitHub Profile
@ovcharik
ovcharik / observable-storage.ts
Created May 23, 2024 09:45
ObservableStorage
import {
BehaviorSubject,
combineLatest,
defaultIfEmpty,
filter,
iif,
map,
Observable,
observeOn,
of,
@ovcharik
ovcharik / novnc-core.ts
Created December 2, 2021 10:31
rxjs wrapper for @novnc/novnc
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="./types/input-keysym.d.ts" />
/// <reference path="./types/input-utl.d.ts" />
/// <reference path="./types/util-browser.d.ts" />
/// <reference path="./types/rfb.d.ts" />
import * as NovncBrowserUtils from '@novnc/novnc/core/util/browser';
import * as NovncInputUtils from '@novnc/novnc/core/input/util';
import NovncKeysym from '@novnc/novnc/core/input/keysym';
import NovncClient from '@novnc/novnc/core/rfb';
@ovcharik
ovcharik / input-keysym.d.ts
Last active June 17, 2022 10:19
@novnc/novnc 1.3.0 declarations
declare module '@novnc/novnc/core/input/keysym' {
export default {
XK_VoidSymbol: 0xffffff, /* Void symbol */
XK_BackSpace: 0xff08, /* Back space, back char */
XK_Tab: 0xff09,
XK_Linefeed: 0xff0a, /* Linefeed, LF */
XK_Clear: 0xff0b,
XK_Return: 0xff0d, /* Return, enter */
XK_Pause: 0xff13, /* Pause, hold */
@ovcharik
ovcharik / wt-tilda.ahk
Last active September 3, 2021 09:59
Autohotkey script. Run/Show/Hide Windows Terminal on top of the screen by F1 hotkey.
#NoEnv
#SingleInstance force
SetWinDelay, -1
DetectHiddenWindows, on
Menu, Tray, NoStandard
; Menu, Tray, Icon, wt-tilda.ico
Menu, Tray, Add, Exit, Exit
@ovcharik
ovcharik / wt-two-finger-scroll.ahk
Created December 4, 2019 20:29
Autohotkey script. Throttle touchpad two finger scrolling in Windows Terminal.
; Config
#Persistent
#SingleInstance force
; 200 wheel events per second rate
#HotkeyInterval 1000
#MaxHotkeysPerInterval 200
DeactivateMenuItem := "Deactivate (Win + Shift + W)"
EnableHScrollMenuItem := "Enable HScroll (Win + Shift + H)"
class Observable {
protected listeners: Map< any, Function > = new Map();
constructor() {}
public subscribe(listener: any, next: Function) {
this.listeners.set(listener, next);
}
@ovcharik
ovcharik / README.md
Last active September 21, 2018 11:20
Декораторы для создания тонкой прослойки между AngularJS и произвольными классами TypeScript

Классы в рамках AngularJS

Ограничение

При наследование не корректно будет работать оператор instanceof

@Contextable("module") class A { }
@Contextable("module") class B extends A {}

const b = new B()

Drag-and-Drop (ng2-dnd)

Draggable

Directive: dnd-draggable

Inputs:

  • dragEnabled: boolean
  • dragData: any - The data that has to be dragged. It can be any JS object.
@ovcharik
ovcharik / cookieStorage.ts
Created January 11, 2018 14:03
Cookie storage with chunks
const cookieStorage = {
get COOKIE() { return window.document.cookie; },
set COOKIE(v: string) { window.document.cookie = v; },
get ITEMS(): { [key: string]: string } {
return this.COOKIE
.split(/;\s*/)
.filter(Boolean)
.map(s => s.match(/^([^=]+)=(.*)$/))
gen = (cur, all, chunk = 10) ->
half = (chunk - 4) // 2
ledge = Math.max(1 , cur - half)
redge = Math.min(all, cur + half)
ldiff = half - (cur - ledge) + ((ledge < half-1) && 2 || (ledge < half) && 1 || 0)
rdiff = half - (redge - cur) + ((cur+half >= all) && 2 || (cur+half+1 == all) && 1 || 0)
prev = 0