Skip to content

Instantly share code, notes, and snippets.

View YordanGeorgiev's full-sized avatar

Yordan Georgiev YordanGeorgiev

View GitHub Profile
@YordanGeorgiev
YordanGeorgiev / puppeteer-click-by-text.js
Created February 5, 2020 15:11 — forked from tokland/puppeteer-click-by-text.js
Click link by text in Puppeteer
const puppeteer = require('puppeteer');
const escapeXpathString = str => {
const splitedQuotes = str.replace(/'/g, `', "'", '`);
return `concat('${splitedQuotes}', '')`;
};
const clickByText = async (page, text) => {
const escapedText = escapeXpathString(text);
const linkHandlers = await page.$x(`//a[contains(text(), ${escapedText})]`);
@YordanGeorgiev
YordanGeorgiev / chk-only-root-can-execute-me.sh
Created November 6, 2019 11:22
[check that script is run under root or sudo] how-to check that script is run under root or sudo
do_chk_only_root_can_execute_me(){
if [[ $(id -u) -ne 0 ]]; then
echo "This script must be run ONLY as THE root"
exit 1
fi
}
@YordanGeorgiev
YordanGeorgiev / pass-env-vars-to-vagrant-guest.sh
Created October 15, 2019 11:43
[how-to pass environement variables to vagrant guest] how-to pass environement variables to vagrant guest
$set_environment_variables = <<SCRIPT
tee "/etc/profile.d/myvars.sh" > "/dev/null" <<EOF
# Ansible environment variables.
export ANSIBLE_STDOUT_CALLBACK=debug
# AWS environment variables.
export AWS_DEFAULT_REGION=#{ENV['AWS_DEFAULT_REGION']}
export AWS_ACCESS_KEY_ID=#{ENV['AWS_ACCESS_KEY_ID']}
export AWS_SECRET_ACCESS_KEY=#{ENV['AWS_SECRET_ACCESS_KEY']}
EOF
@YordanGeorgiev
YordanGeorgiev / how-to-generate-scala-from-xlsd.sh
Created May 10, 2019 10:18
[how-to generate scala from xlsd] how-to generate scala code from xsd
# chk the followin tool - http://scalaxb.org/setup
# chk the prerequisite tool - http://www.foundweekends.org/conscript/setup.html
# install the conscript , check your proxy settings first - your should be able to connect to the Internet
cd ~
wget https://raw.githubusercontent.com/foundweekends/conscript/master/setup.sh
vim setup.sh
# and intstall it
sh setup.sh # wait patiently - all jvm stuff is usually slow ...
@YordanGeorgiev
YordanGeorgiev / mac-cheat-sheet.sh
Created April 23, 2019 19:14
[mac-cheat-sheet] mac-cheat-sheet #mac #cheat-sheet
#file: doc/cheat-sheets/mac-cheat-sheet.sh
# how-to check that a DNS server is working to a target url
nslookup <<target-uri>> <<dns-server-to-check>>
nslookup www.google.fi 8.8.8.8
dig @8.8.8.8 www.apple.com
# how-to get hw info - lsb_release -a for mac
system_profiler SPSoftwareDataType
@YordanGeorgiev
YordanGeorgiev / setup-local-s3-with-minio.sh
Created March 28, 2019 14:32
[setup-local-s3-with-minio] setup local s3 with minio #minio #setp #s3 #s3a
#!/bin/bash
set -x
#set -eu -o pipefail
# file: CI/start-minio.sh
export minio_data_dir='/opt/deptmnt/data/minio-data'
mkdir -p $minio_data_dir
# set credentials for the server
@YordanGeorgiev
YordanGeorgiev / docker-cheat-sheet.sh
Last active March 28, 2019 14:29
[docker-cheat-sheet.sh] docker cheat-sheet #docker #cheat-sheet
# create a docker image in the current directory from the Dockerfile in it
docker build --tag=the-tag .
# list all the images
docker images -a
# remove all the images
docker rmi $(docker images -q)
# remove all the containers
@YordanGeorgiev
YordanGeorgiev / how-to-fork-a-new-git-proj.sh
Last active March 9, 2019 13:20
[how-to-fork-a-new-git-proj] how-to for a new git proj by re-using the history of an old one #git #fork #app #project
# add the remote git host named "fork"
git remote add fork [email protected]:UserName/src_proj.git
# fetch all the data from the for
git fetch fork
# check the branches
git branch -a
# create and checkout the local target branch name
@YordanGeorgiev
YordanGeorgiev / msgs-model-in-scala.scala
Created January 24, 2019 12:14
[msgs-model-in-scala] a simple msgs model in scala #scala #model #messages #msg #msgs
object Msgs {
case class Msg(
code: Int,
name: String,
description: String = null
)
val infMsgs = List(
Msg(1, "inf-msg-01"),
@YordanGeorgiev
YordanGeorgiev / get-server-data-with-axious.js
Created January 23, 2019 12:52
[get-server-data-with-axious] how-to get server data with axios #javascrit #axios #get
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
function getUrlParams (){
var url_params = new URLSearchParams();
if( window.location.toString().indexOf("?") != -1) {
var href_part = window.location.search.split('?')[1]
href_part.replace(/([^=&]+)=([^&]*)/g,
function(m, key, value) {
var attr = decodeURIComponent(key)