Skip to content

Instantly share code, notes, and snippets.

View Sominemo's full-sized avatar
💼
Working

Sominemo Sominemo

💼
Working
View GitHub Profile
@Sominemo
Sominemo / main.dart
Last active November 23, 2022 11:28
Flutter password validation bullet list example
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@Sominemo
Sominemo / monobank-corp-api-ru.md
Last active November 6, 2023 22:20
Monobank Corp API Interaction

Mono Corp API Interaction

Also available: English version

Обозначения

  • Secret Proof: Секретный пароль, который должен знать только сервер monobank;
  • Ответ: JSON сериализированный вывод с Content-Type: application/json и кодом ответа 200 OK;
  • %METHOD% /%resource% Monobank Request: HTTP %METHOD% (GET|POST|...) запрос к https://api.monobank.ua/%resource% -> POST /personal/auth/request Monobank Request. См. Отправка запросов в Monobank;
  • Закрытый ключ: Сгенерированный OpenSSL ключ;
@Sominemo
Sominemo / devtools_detector.js
Last active May 17, 2021 16:11
DevTools Detector
function detectDevTools() {
let h = window.outerWidth - window.innerWidth > 160;
let v = window.outerHeight - window.innerHeight > 160;
if (
(h && v) ||
!((window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized) || h || v)
) {
return { isOpen: false, orientation: null };
}
@Sominemo
Sominemo / Mono Corp API Proxy Protocol.md
Last active August 16, 2022 06:44
Mono Corp API Proxy

Mono Corp API Proxy Protocol 1.3

This document describes the protocol of Mono Corp API Proxy (MCAP). This protocol is created for Mono PWA project.

Entities

  • Root: describes the publicly available URL path, which contains methods as subfolders;
  • Method: Named public command, the way to interact with MCAP for different actions. A simulated subfolder of Root;
  • Secret Proof: A password, that elevates access rights for the request;
  • Public Method: Generally available method, that is intended to be called by the client app;
  • Service Method: A method, that must not be called by the client app, requires Secret Proof;
  • Response: JSON marshaled output of Method with application/json Content-Type and 200 OK response code;

Keybase proof

I hereby claim:

  • I am sominemo on github.
  • I am sominemo (https://keybase.io/sominemo) on keybase.
  • I have a public key ASDVhrl53oijcLlNBZ9U4GUduo0BD4Z2HsT_gXOpdLt5HQo

To claim this, I am signing this object:

class OnWordListener{constructor(e,s){this.parent=s,this.id=e}get info(){return this.parent.getById(this.id)}unset(){this.parent.unset(this.id)}}class OnWord{constructor(e=!1,s,t=!1,i=!1){this.register=[],this.disabled=!1,this.listener=this.handler.bind(this),document.addEventListener("keypress",this.listener),t&&this.listen(e,s,t,i)}listen(e,s,t=!1,i=!1){let r=this.register.findIndex(s=>s.string===e&&t===s.case&&i===s.debug);return-1===r?this.register.push({string:t?e:e.toLowerCase(),stage:0,callback:[s],case:t,debug:i}):this.register[r].callback.push(s),r=-1===r?this.register.length-1:r,new OnWordListener(r,this)}getById(e){return this.register[e]}handler(e){if(this.disabled)return;const{key:s}=e,t=s.toLowerCase();this.register.forEach(e=>{const i=e.case?s:t;e.string[e.stage]===i?(e.stage++,e.debug&&console.log(`${i} = ${e.string[e.stage-1]}`)):(e.debug&&console.log(`${i} != ${e.string[e.stage]}`),e.stage=0),e.stage>=e.string.length&&(e.stage=0,e.callback.forEach(e=>e()))})}unset(e){this.register.splice(e,1
@Sominemo
Sominemo / OnWord.class.js
Last active January 5, 2021 05:23
onWord (And OnWordListener) class to react on typing with a callback (minified: https://gist.github.com/Sominemo/ff8d65baf08e7dfaa24a2973f2bca4d6)
/**
* @typedef {Object} OnWordListenerInfo
* @property {function[]} callback Callbacks for the listener
* @property {boolean} case Case senisvity
* @property {boolean} debug Debug mode for the listener
* @property {number} stage Symbol number which will be checked on the next keypress
* @property {string} string String the item is listening for
*/
class OnWordListener {
@Sominemo
Sominemo / onword.min.js
Last active May 31, 2018 20:31
Listening for pressing keys from string in correct order and giving callback
onword={reg:{},set:(d,e,f)=>{f||(d=d.toLowerCase()),document.addEventListener("keypress",g=>{onword.listen(d,g,e,f)}),onword.reg[d]=0},listen:(d,e,f,g)=>{if(!g)var h=e.key.toLowerCase();else var h=e.key;if(d[onword.reg[d]]&&h===d[onword.reg[d]])onword.reg[d]++;else{onword.reg[d];onword.reg[d]=0}onword.reg[d]>=d.length&&(f(),onword.reg[d]=0)}};
// onword.set(): Add new KeyPress-listener
// @param d* {string} - String we're listening for
// @param e* {function} - Callback
// @param f {bool} - Case-sensitive
onword.set("Hello World", ()=>{alert("Welcome to JavaScript!");})
@Sominemo
Sominemo / onword.js
Last active May 31, 2018 20:32
Listening for pressing keys from string in correct order and giving callback
onword = {
reg: {},
debug: false,
set: (a, c, s) => {
if (!s) a = a.toLowerCase();
document.addEventListener("keypress", (b) => {
onword.listen(a, b, c, s);
});