Skip to content

Instantly share code, notes, and snippets.

View profiprog's full-sized avatar

Milan Skuhra profiprog

View GitHub Profile
@profiprog
profiprog / iptoos.py
Created May 24, 2021 11:23
One line code
ip2bin = lambda ip: ' '.join([bin(int(n))[2:].zfill(8) for n in ip.split(".")])
bin2ip = lambda ip: '.'.join([str(int(n,2)) for n in ip.split(' ')])
@profiprog
profiprog / ssh_keys-cheatsheet.md
Last active October 17, 2020 08:56
Generate SSH Keys

== Generate new SSH key:

COMMENT="Here put your comment like 'email' or 'username@hostname'"
ssh-keygen -t rsa -b 4096 -C "$COMMENT" -N ''

Private key will be strored in ~/.ssh/id_rsa and public key in ~/.ssh/id_rsa.pub

Note: If you are using windows you kan use putty.

@profiprog
profiprog / simple-compressing.md
Last active May 7, 2024 20:14
Simple compressing base64 string in JavaScript

Story

In needed include base64 encoded simple image into HTML page in two formats:

1st as PNG format has length 196 characters and looks like this:

iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAWElEQVR42mNkwA/qgbgRnwJGAgb8BwI7RkbGw5QYUAs0oGXUAPwGgKKqgYF0ANLTyAi1xhZI2WOYzsjYDJTbC2QewGHIwcERBsPcgHqgAX8pMQAcxfhyIwATTkxL+hgX2QAAAABJRU5ErkJggg==

2nd as CUR format has length 1536 characters and looks like this:

`AAACAAEAEBAAAAcABwBoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAQAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP///z0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH////98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD/////fAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////3wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////98AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

@profiprog
profiprog / wordpress-app.sh
Last active August 29, 2018 08:07
Bash script to install, remove and purge data of docker wordpress image.
#!/bin/bash
DOMAIN="www.example.xy" # set your own domain
INSTANCE_NAME="appweb" # set your app name
INSTANCE_PORT="1090" # set dedicated port
DB_HOST="dbhost:3306" # set connection to database ...
DB_USER="db_user"
DB_PSWD="db_password"
DB_NAME="db_schema"
HTML_DIR="$(cd "$(dirname "$0")"; pwd)/html-content" # here is stoted html content
@profiprog
profiprog / update-java-cacerts.sh
Created August 4, 2018 12:02
Automatically download and install server SSL certificate to java keystore (keytool)
#!/bin/bash
fail() { echo -e "\033[1;31mError:\033[0m" "$@" >&2; exit 1; }
warn() { echo -e "\033[1;33mWarning:\033[0m" "$@"; }
info() { echo -e "\033[1;32mInfo:\033[0m" "$@"; }
printHelp() { cat << EOF
Usage: $0 <hostname>
-keystore <file> [-storepass <password>]
[-keytool <path>]
[-quiet] [-test|-testonly]