Skip to content

Instantly share code, notes, and snippets.

@kolserdav
kolserdav / sh
Last active January 13, 2024 18:46
Watch separate processes by name in Linux
#!/usr/bin/bash
# Option H shows processes with threads
# Command sed ':a; N; $!ba; s/\n/,/g' replaces \n to , if process have some subprocesses
watch -d ps -auH -q $(pgrep "Process name 1" | sed ':a; N; $!ba; s/\n/,/g'),$(pgrep "Process name 2")
@kolserdav
kolserdav / frontal_face_recognition.cpp
Created January 14, 2021 11:40
OpenCV face recognition example
#include <vector>
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/objdetect.hpp>
#include <iostream>
#include <vector>
using namespace cv;
using namespace std;
@kolserdav
kolserdav / npm-cli-colors.js
Created June 27, 2020 17:02
Npm cli colors
let Reset = "\x1b[0m",
Bright = "\x1b[1m",
Dim = "\x1b[2m",
Underscore = "\x1b[4m",
Blink = "\x1b[5m",
Reverse = "\x1b[7m",
Hidden = "\x1b[8m",
FgBlack = "\x1b[30m",
FgRed = "\x1b[31m",
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.8.0
ports:
- "9200:9200"
- "9300:9300"
networks:
- logging
ulimits:
memlock:
soft: -1
import React, { useState, useEffect } from 'react';
const useStateWithPromise = defaultVal => {
let [state, setState] = useState({
value: defaultVal,
resolve: () => {}
});
useEffect(
@kolserdav
kolserdav / https.js
Created January 22, 2020 07:50
NodeJs Express SSL certigicate
const app = require('express')();
const https = require('https');
const fs = require('fs');
//GET home route
app.get('/', (req, res) => {
res.send('Hello World');
});
//openssl req -x509 -newkey rsa:4096 -keyout key.pem -out cert.pem -days 365
// we will pass our 'app' to 'https' server
@kolserdav
kolserdav / drop.sql
Created October 7, 2019 09:55
Drop procedure
DROP PROCEDURE IF EXISTS update_or_insert;
DELIMITER $$
CREATE PROCEDURE update_or_insert(name VARCHAR(80), email VARCHAR(50))
@kolserdav
kolserdav / .vimrc
Created September 10, 2019 01:48
Vimrc example file
" Vundle.vim section
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'vim-scripts/vim-auto-save'
call vundle#end()
const storeCategories = createStore((state = [], action) => {
switch (action.type) {
case 'ADD_CATEGORIES':
return state.concat([action.categories]);
default:
return state
}
});
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;