Skip to content

Instantly share code, notes, and snippets.

View voznik's full-sized avatar
🤔
Open for opportunities

Vadym Parakonnyi voznik

🤔
Open for opportunities
View GitHub Profile
@voznik
voznik / node-logger.js
Created June 3, 2023 21:48 — forked from htdangkhoa/node-logger.js
Override node js console.
import { readFileSync } from 'fs';
import { resolve } from 'path';
const pkg = JSON.parse(
readFileSync(resolve(process.cwd(), 'package.json'), 'utf-8').toString(),
);
const DATE_FORMAT = 'DD-MM-YYYY-hh:mm:ss.SSS';
const colors = {
@voznik
voznik / customize-mx-master-ubuntu.md
Created February 28, 2023 08:53 — forked from bogdanRada/customize-mx-master-ubuntu.md
Custom keymap for Logitech MX Master 2S mouse on Ubuntu

First, install Solaar to see the battery level on the taskbar

sudo apt-get install solaar

To remap the keys, install

sudo apt-get install xbindkeys xautomation
@voznik
voznik / Jest_GitLab_CI.md
Created October 5, 2021 10:36 — forked from rishitells/Jest_GitLab_CI.md
Setting up Jest tests and coverage in GitLab CI

Configuring Jest Tests in GitLab CI

1. Add GitLab CI configuration file in the root

In the root of your project, add .gitlab-ci.yml with the configuration below.

image: node:latest

stages:
@voznik
voznik / electron-devtools.ts
Created September 1, 2021 19:32
electron devtools globalShortcut
import { remote } from 'electron'
remote.globalShortcut.register('CommandOrControl+Shift+K', () => {
remote.BrowserWindow.getFocusedWindow().webContents.openDevTools()
})
window.addEventListener('beforeunload', () => {
remote.globalShortcut.unregisterAll()
})
@voznik
voznik / better-scroll-restoration-logic-angular.ts
Created January 28, 2021 11:29 — forked from iffa/better-scroll-restoration-logic-angular.ts
Custom scroll position restoration logic for Angular 2+, that doesn't consider query parameter changes in route as forward navigation, thus preventing certain scenarios where you don't want query parameter changes to scroll-to-top as they would with 'scrollPositionRestoration: enabled'.
export class AppModule {
constructor(private router: Router, private viewportScroller: ViewportScroller) {
this.handleScrollOnNavigation();
}
/**
* When route is changed, Angular interprets a simple query params change as "forward navigation" too.
* Using the pairwise function allows us to have both the previous and current router events, which we can
* use to effectively compare the two navigation events and see if they actually change route, or only
* the route parameters (i.e. selections stored in query params).
@voznik
voznik / detect_touch.js
Created November 19, 2020 08:27 — forked from esedic/detect_touch.js
Various JavaScript methods for detecting touch/mobile devices
// Method 1
var isTouchDevice =
(('ontouchstart' in window) ||
(navigator.MaxTouchPoints > 0) ||
(navigator.msMaxTouchPoints > 0));
if(!isTouchDevice){
console.log('is not touch');
}else{
console.log('is touch');
}
@voznik
voznik / converts-webfont-to-base64.js
Created June 26, 2020 06:05 — forked from arielsalminen/converts-webfont-to-base64.js
Convert Google WOFF font to base64 format and inline to <head> of document
// Get binary file using XMLHttpRequest
function getBinary(file) {
var xhr = new XMLHttpRequest();
xhr.open("GET", file, false);
xhr.overrideMimeType("text/plain; charset=x-user-defined");
xhr.send(null);
return xhr.responseText;
}
// Base64 encode binary string
@voznik
voznik / config.fish
Created June 23, 2020 08:22 — forked from dmccombs/config.fish
A simple way to use the GNOME keyring for SSH key managment in fish shell
# Add this to the bottom of your config.fish file
# Set SSH to use Gnome keyring
set -gx SSH_AUTH_SOCK (gnome-keyring-daemon --start | grep "^SSH_AUTH_SOCK" | awk -F "=" '{print $2}')
@voznik
voznik / drawing-board.component.ts
Created June 15, 2020 14:43 — forked from anupkrbid/drawing-board.component.ts
A example canvas component for drawing in an angular 6 app using rxjs 6.
import {
AfterViewInit,
Component,
ElementRef,
Input,
OnDestroy,
ViewChild
} from '@angular/core';
import { fromEvent } from 'rxjs';
import { pairwise, switchMap, takeUntil } from 'rxjs/operators';
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {