Skip to content

Instantly share code, notes, and snippets.

View yukal's full-sized avatar
🙃
Haven't you tried it like this? ))

Alexander yukal

🙃
Haven't you tried it like this? ))
View GitHub Profile
function getType(obj) {
const signature = Object.prototype.toString.call(obj);
return signature.slice(8,-1).toLowerCase();
}
const cases = [
// undefined
undefined,
// null
@yukal
yukal / ssl_signature.js
Last active June 27, 2020 22:36
Create and check signature
// Create certificate
// https://www.akadia.com/services/ssh_test_certificate.html
//
// 1. Generate a Private Key
// openssl genrsa -des3 -out ssl.key 4096
//
// 2. Generate a CSR (Certificate Signing Request)
// openssl req -new -key ssl.key -out ssl.csr
//
// 3. Remove Passphrase from Key
@yukal
yukal / usracc_wwwdata.sh
Last active July 31, 2019 05:56
Create a system account www-data with the same UID and GID
# Create www-data account
useradd -s /sbin/nologin -d /var/www -r -M -U -u 777 www-data
# Set the ownership to www directory
# chown -R root:www-data /var/www
chown -R www-data:www-data /var/www
# Set permissions of child files and directories inside the www directory
find /var/www -type d -exec chmod 2775 {} +
find /var/www -type f -exec chmod 0664 {} +
@yukal
yukal / Vagrantfile
Created June 27, 2019 15:27
Vagrantfile bootstraping the gpg, nvm
Vagrant.configure("2") do |config|
config.vm.box = "debian/jessie64"
config.vm.box_check_update = false
config.vm.provider "virtualbox" do |vb|
vb.name = "debian"
vb.cpus = 1
vb.memory = 1024
vb.gui = false
end
@yukal
yukal / start-docker
Last active August 13, 2019 09:12
The universal bash script to start Docker container or image
#!/usr/bin/bash
# This is a bash script for backend serving
# using the Docker
#
# Author: Yukal Alexander <yukal.alexander@gmail.com>
# License MIT
# Version: 3.0
# Set variables
@yukal
yukal / .bashrc
Last active March 22, 2022 18:15
.bashrc
# Generate Hash
# Usage:
# genhash
# genhash 64
function genhash() {
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
}
# Get External IP
# External IP
@yukal
yukal / demo-bash-colors.sh
Last active November 4, 2018 14:20
Bash Colors and Text Style Demonstration
#!/bin/bash
# Bash Color and Style Demonstration
# Author: Yukal Alexander <yukal@email.ua>
# License MIT
# Version: 3.0
#
# UTF-8 encoding table and Unicode characters
# https://www.utf8-chartable.de/unicode-utf8-table.pl?start=9472&unicodeinhtml=dec
@yukal
yukal / docker-vuejs
Last active November 11, 2018 16:23
Serving a vuejs project using docker and webpack
#!/bin/sh
# Author: Yukal Alexander <yukal@email.ua>
# License MIT
# Version: 2.0
# Usage:
# * $ ./docker-vuejs init - Init Project (starts 'vue init webpack .')
# - $ ./docker-vuejs - Start Project (starts 'webpack-dev-server')
# $ ./docker-vuejs clean - Remove Project
@yukal
yukal / backup-boot-sector.sh
Last active December 13, 2017 12:47
Backup and restore boot sector
#!/bin/bash
# BACKUP
# Save info in text-file (parted)
sudo parted /dev/sdX print > sdX-partiotion.info
# Save info in text-file (sfdisk)
sudo sfdisk -d /dev/sdX > sdX-partiotion.info
# Save info in text-file (gdisk)
sudo gdisk -l /dev/sdX > sdX-partiotion.info
@yukal
yukal / archlinux.sh
Last active December 16, 2017 09:00
archlinux.sh
#!/bin/bash
# Create Partitions
cgdisk /dev/sda
cgdisk /dev/sdb
# Format Partitions (SSD)
mkfs.fat -F32 /dev/sda1
mkfs.ext4 /dev/sda2 -L root
mkfs.ext4 /dev/sdb5 -L home