Skip to content

Instantly share code, notes, and snippets.

@griga
griga / promise-utils.test.ts
Created July 26, 2023 07:41
promise retry function realisation
/* eslint-disable no-console */
/* eslint-disable no-unused-vars */
/* eslint-disable prefer-promise-reject-errors */
/* eslint-disable jest/no-focused-tests */
/* eslint-disable jest/no-commented-out-tests */
/* eslint-disable jest/no-disabled-tests */
import {
promiseFnRetry,
retryWhenToPromise,
promiseRetryRx,
@griga
griga / rsa-code-listing.java
Last active May 21, 2020 00:55
just listing
// [0] файл program.java
// стартовий файл. запускає форму StartForm [1] в якій можна обрати режим 'сервера' або режим 'клієнта'
using System;
using System.Net;
using System.Net.Sockets;
namespace ChatRSA
{
using System;
using System.Net;
using System.Net.Sockets;
namespace ChatRSA
{
class Program
{
static void Main()
{
@griga
griga / machine.js
Created March 20, 2020 11:44
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id: 'airship',
initial: 'idle',
context: {
fuel: 2000,
damage: 0
},
states: {
idle: {
@griga
griga / tag.effects.ts
Last active June 8, 2019 10:57
Code Example. Frontend and Backend code for managing Tag entity. NgRx Entity + Apollo GraphQL client and server
/**
* Tag CRUD Effects
*/
@Injectable()
export class TagEffects {
/**
* Load tags into store with GraphQL
* based on search criteria and pagination
*/
@griga
griga / quill-editor.component.ts
Created May 4, 2019 11:31
angular quill editor component
import { Component, AfterContentInit, ViewChild, Input, Output, EventEmitter, OnChanges, SimpleChanges, ChangeDetectionStrategy, OnDestroy } from '@angular/core';
import Quill from 'quill'
import { Subject, Subscription } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
@Component({
selector: 'm22-quill-editor',
template: `
<div #quillDiv ></div>
@griga
griga / gist:a7a8ff18c570aa2315a06f5f105d1efa
Last active April 19, 2019 23:32
mocha vscode debug setup
// package.json test script
"test:watch": "mocha --extension spec.js --recursive --colors --full-trace --require test/index.js --watch"
"test": "mocha --extension spec.js --recursive --colors --full-trace --require test/index.js"
//.vscode/launch.json for debug
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
@griga
griga / objectis.ts
Last active February 1, 2019 12:40
typescript bson objectid for mongodb
// use function `generate` to make mongodb compatible objectids
// inspired by https://github.com/williamkapke/bson-objectid
const MACHINE_ID = Math.floor(Math.random() * 0xffffff);
const pid = Math.floor(Math.random() * 100000) % 0xffff;
let index = Math.floor(Math.random() * 0xFFFFFF);
function hex(length, n) {
n = n.toString(16);
return n.length === length ? n : "00000000".substring(n.length, length) + n;
}
@griga
griga / objectid.js
Last active February 1, 2019 12:23
javascript bson objectid for mongodb
// use function `generate` to make mongodb compatible objectids
// inspired by https://github.com/williamkapke/bson-objectid
var MACHINE_ID = Math.floor(Math.random() * 0xffffff);
var index = parseInt(Math.random() * 0xFFFFFF, 10);
var pid =
(typeof process === "undefined" || typeof process.pid !== "number"
? Math.floor(Math.random() * 100000)
: process.pid) % 0xffff;
0 docs
https://nodejs.org/uk/
https://nodejs.org/dist/latest-v8.x/docs/api/
1 simple app
npm init -y | git init
express
touch index.js .gitignore
2 tools