Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Coding for life and fun

Jakub Zomerfeld devzom

:octocat:
Coding for life and fun
View GitHub Profile
View promises.js
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 Sep 25, 2021 — forked from jmcaldera/ssh_multikeys.md
Multiple SSH Keys macOS
View ssh_multikeys.md

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 Sep 25, 2021
MacOS BigSur add permission to /var/www folder to use with Laravel symlink
View MacOs-Laravel-var_www-symlink-permissions.txt
@devzom
devzom / add-ssh-on-ubuntu.txt
Created Dec 20, 2021
SSH: How to use existing SSH key on my newly installed Ubuntu
View add-ssh-on-ubuntu.txt
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 / compareEnvs.js
Created Jan 14, 2022
javascript: Function to compare different .env files
View compareEnvs.js
/*
* 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 / generate-seo-robots-agents-sitemap.js
Last active Jan 19, 2022
JS: Nuxt: Generate sitemap UserAgent based on provided array
View generate-seo-robots-agents-sitemap.js
/*
* @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 / nuxt_JSON-LD_head-SEO.js
Created Mar 5, 2022
Nuxt: Add JSON-LD schema markup for SEO in Nuxt.js
View nuxt_JSON-LD_head-SEO.js
data(){
return ({
description:'Description of the site'
})
}
head(){
return({
title: 'Home page',
meta: [
{
@devzom
devzom / index.html
Last active Mar 16, 2022
CSS: Animated smooth anchor scroll with anchor margin
View index.html
<!-- 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 Mar 16, 2022
docker: Check if Docker container exist and delete it
View docker-check-container.sh
# 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 Mar 16, 2022
bash: Read .env file variable in Bash
View read-env.sh
# 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: