Skip to content

Instantly share code, notes, and snippets.

View paveltretyakovru's full-sized avatar
🐯
Om 🔱

Pavel Tretyakov paveltretyakovru

🐯
Om 🔱
  • St.-Petersburg (Russia)
View GitHub Profile
@paveltretyakovru
paveltretyakovru / draggable-marker.component.tsx
Last active August 5, 2021 18:54
React Mapbox-GL draggable marker component
import MapboxGL from 'mapbox-gl';
import React, { useEffect, useRef, useState, MutableRefObject } from 'react';
type CoordinatesType = [number, number];
interface DraggableMarkerProps {
coordinates: CoordinatesType;
map?: MapboxGL.Map;
children?: any;
@paveltretyakovru
paveltretyakovru / install-argouml.sh
Created July 7, 2021 15:14
ArgoUML instalation script (checked)
#!/bin/sh
if [ "root" != "$(whoami)" ]; then
echo "You must run this command as root" 1>&2
exit 1
fi
set -x
# Download and extract
if [ ! -z "${1}" ]; then
@paveltretyakovru
paveltretyakovru / config-overrides.js
Last active June 26, 2021 16:36
To move CRA application to other directory than src (for example to src/frontend folder)
const path = require('path');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
module.exports = {
paths: function (paths, env) {
paths.appIndexJs = path.resolve(__dirname, 'src/frontend/index.js');
paths.appSrc = path.resolve(__dirname, 'src/frontend');
return paths;
},
@paveltretyakovru
paveltretyakovru / chocolatey-packages.bat
Created May 7, 2020 14:40
Fullstack developer windows bat script to install chocolatey packages
choco install --yes robo3t
@paveltretyakovru
paveltretyakovru / get-ips.js
Created April 14, 2020 14:07
Script to print current network interfaces and their ip addressess
'use strict';
var os = require('os');
var ifaces = os.networkInterfaces();
module.exports = () => {
const result = [];
Object.keys(ifaces).forEach(function (ifname) {
var alias = 0;
@paveltretyakovru
paveltretyakovru / make-nvm-sude.sh
Created April 8, 2020 21:34
Script to fix "sudo npm install ..." - "npm is not comand" when node installed with using NVM
n=$(which node); \
n=${n%/bin/node}; \
chmod -R 755 $n/bin/*; \
sudo cp -r $n/{bin,lib,share} /usr/local
@paveltretyakovru
paveltretyakovru / add-root-user.sql
Created October 6, 2019 16:16
Create user with root privilegies
# mysql -u root -p
CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'some_very_complex_password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'@'localhost';
FLUSH PRIVILEGES;
@paveltretyakovru
paveltretyakovru / .vimrc
Last active September 30, 2022 13:05
vimrc configuration file
" Tabulation highlights syntax
set tabstop=2
set shiftwidth=2
set smarttab
set expandtab " Copy current line tabs to new line
set smartindent " ...like a expandtab but it adding {} tabs
" ========================= Short keys settings" ==============================
" NERDTree
map <silent> <C-b> :NERDTreeToggle<CR> " NERDTree toggle
@paveltretyakovru
paveltretyakovru / jquery-check-to-scroll-and-scroll-to-element.js
Created July 9, 2019 07:36
Проверить существует ли прокрутка сайта, если да, то прокрутить страницу до элемента
if ($(document).height() > $(window).height()) {
$([document.documentElement, document.body]).animate({
scrollTop: $("#certificate-info h2").offset().top
}, 2000);
}
@paveltretyakovru
paveltretyakovru / detach-dynamic-component.ts
Created March 13, 2019 22:50
Creating Angular dynamic component with detaching data
export class ValidationMessageDirective implements AfterViewInit, OnDestroy {
private validationMessageComponent: ComponentRef<ValidationMessageComponent> = null;
ngAfterViewInit(): void {
let factory = this.componentFactoryResolver.resolveComponentFactory(this.vmComp);
this.ngOnDestroy();
this.validationMessageComponent = this.viewContainer.createComponent(factory, null, this.viewContainer.injector);
this.validationMessageComponent.changeDetectorRef.detectChanges();
}