Skip to content

Instantly share code, notes, and snippets.

View devzom's full-sized avatar
:octocat:
Coding for life and fun

Jakub Zomerfeld devzom

:octocat:
Coding for life and fun
View GitHub Profile
function loadScript(src) {
return new Promise(function(resolve, reject) {
let script = document.createElement('script');
script.src = src;
script.onload = () => resolve(script);
script.onerror = () => reject(new Error("Script load error: " + src));
document.head.append(script);
});
@devzom
devzom / ssh_multikeys.md
Last active September 25, 2021 07:40 — forked from jmcaldera/ssh_multikeys.md
Multiple SSH Keys macOS

Multiple SSH Keys on same client

Check if you have existing keys by opening the terminal and entering: ssh-add -l OR ls -al ~/.ssh and check for any file called (usually) id_rsa or similar

Identify the host you're using your current key for. You probably added this key to, for example your github or gitlab account. We will use this later on.

If you don't have a config file on ~/.ssh folder, you will need to create one. We'll get back to this later.

@devzom
devzom / MacOs-Laravel-var_www-symlink-permissions.txt
Created September 25, 2021 13:50
MacOS BigSur add permission to /var/www folder to use with Laravel symlink
@devzom
devzom / add-ssh-on-ubuntu.txt
Created December 20, 2021 10:33
SSH: How to use existing SSH key on my newly installed Ubuntu
cp /path/to/my/key/id_rsa ~/.ssh/id_rsa
cp /path/to/my/key/id_rsa.pub ~/.ssh/id_rsa.pub
# change permissions on file
sudo chmod 600 ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa.pub
# start the ssh-agent in the background
eval $(ssh-agent -s)
# make ssh agent to actually use copied key
ssh-add ~/.ssh/id_rsa
@devzom
devzom / generate-seo-robots-agents-sitemap.js
Last active January 19, 2022 09:08
JS: Nuxt: Generate sitemap UserAgent based on provided array
/*
* @created: 18/12/2021
* @author Jakub [dev.zomerfeld@gmail.com]
* @summary Utils funtion to generate an array of
* UserAgents provided in structured schema
* to use with Robots Nuxt module https://github.com/nuxt-community/robots-module
*/
const agentsArray = [
'Abonti',
@devzom
devzom / compareEnvs.js
Created January 14, 2022 13:10
javascript: Function to compare different .env files
/*
* Created: 14/1/2022 by Jakub Zomerfeld / dev.zomerfeld@gmail.com
*/
const fs = require('fs')
const path = require('path')
const dotenv = require('dotenv')
/**
*
@devzom
devzom / nuxt_JSON-LD_head-SEO.js
Created March 5, 2022 09:49
Nuxt: Add JSON-LD schema markup for SEO in Nuxt.js
data(){
return ({
description:'Description of the site'
})
}
head(){
return({
title: 'Home page',
meta: [
{
@devzom
devzom / index.html
Last active March 16, 2022 13:55
CSS: Animated smooth anchor scroll with anchor margin
<!-- step 3 -->
<!-- It's important to add tabindex="-1" to all anchor tags -->
<section id="section1" tabindex="-1">Section 1</section>
@devzom
devzom / docker-check-container.sh
Last active March 16, 2022 14:27
docker: Check if Docker container exist and delete it
# Goal of tghis script is to prompt for Docker container name, if it's skipped it will used infile defined name of container and then will search for specific container and delete it.
# Set container default name as variable
CONTAINER=testContainerName
echo -n "Enter Docker container name (if skipped default from file will be used): "
read containerName
# Check if prompted value isNotEmpty
if [ $containerName ]; then
@devzom
devzom / read-env.sh
Created March 16, 2022 14:55
bash: Read .env file variable in Bash
# this will skip search for lines with variable starting with # (hashtag) ex: # VAR1 as its commented out
# Ex: we have .env file with variables:
# #VAR1=123
# VAR2=xyz
# NPM_TOKEN=12312323fdf21313
export "$(grep -vE "^(#.*|\s*)$" .env)"
# didn't respond VAR1 as it contain #, so it's commented out.
# responds with single value ex NPM_TOKEN: