Skip to content

Instantly share code, notes, and snippets.

View megamcloud's full-sized avatar

Megam.Cloud megamcloud

View GitHub Profile
@megamcloud
megamcloud / generate_docker_cert.sh
Created November 10, 2019 15:11 — forked from bradrydzewski/generate_docker_cert.sh
Generate trusted CA certificates for running Docker with HTTPS
#!/bin/bash
#
# Generates client and server certificates used to enable HTTPS
# remote authentication to a Docker daemon.
#
# See http://docs.docker.com/articles/https/
#
# To start the Docker Daemon:
#
# sudo docker -d \
@megamcloud
megamcloud / instructions.md
Created August 11, 2018 09:51 — forked from andrewn/instructions.md
Testing SSL (LetsEncrypt certificate and loopback domain)

Testing SSL (LetsEncrypt certificate and loopback domain)

General approach

This sets up a publically-available domain that loops back to localhost IP address 127.0.0.1. For example, this address could be localhost.example.com if we controlled the example.com domain. This relies on having a public domain name whose DNS records you can control. We can then generate LetsEncrypt certificates for this domain.

Our HTTP server runs on localhost:80 (default HTTP port). This lets us visit http://localhost.example.com in a web browser and see the server running on localhost:80.

We then run an HTTPS proxy server on localhost:443 (default HTTPS port) that uses the LetsEncrypt certificates we generated for localhost.example.com. Visiting https://localhost.example.com hits the proxy, which returns the correct certificates meaning the browser displays the "Secure" message. The proxy then passes the request through to the HTTP server.

@megamcloud
megamcloud / my.cnf
Created August 7, 2018 18:24 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaSQL (on cPanel/WHM servers)
# Optimized my.cnf configuration for MySQL/MariaSQL on cPanel/WHM servers
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# === Updated July 2018 ===
#
# The settings provided below are a starting point for a 2GB - 4GB RAM server with 2-4 CPU cores.
# If you have less or more resources available you should adjust accordingly to save CPU,
# RAM and disk I/O usage.
# The settings marked with a specific comment or the word "UPD" after the value
@megamcloud
megamcloud / 1-lxd.sh
Created August 6, 2018 18:33 — forked from yelizariev/1-lxd.sh
LXD+dockers+nginx. Remote development for several developer on a single server. LATEST VERSION is here: https://odoo-development.readthedocs.io/en/latest/remote-dev/lxd/lxd.html
# For understanding LXC see https://wiki.debian.org/LXC
# Based on:
# lxd + docker: https://stgraber.org/2016/04/13/lxd-2-0-docker-in-lxd-712/
# lxd network (static ip): https://stgraber.org/2016/10/27/network-management-with-lxd-2-3/
LXD_NETWORK="dev-network2"
# install lxd 2.3+
apt-get install software-properties-common
@megamcloud
megamcloud / jdk_download.sh
Created August 4, 2018 08:45 — forked from P7h/jdk_download.sh
Script to download JDK / JRE / Java binaries from Oracle website from terminal / shell / command line / command prompt
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
@megamcloud
megamcloud / get-image-config.sh
Created August 4, 2018 00:16 — forked from cirocosta/get-image-config.sh
Retrieves the configuration of images pushed to Docker registries - see https://ops.tips/blog/inspecting-docker-image-without-pull/ for more information
#!/bin/bash
# Retrieves image configuration using
# private registries without authentication
set -o errexit
# Address of the registry that we'll be
# performing the inspections against.
# This is necessary as the arguments we
@megamcloud
megamcloud / benchmark+go+nginx.md
Created July 30, 2018 07:31 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@megamcloud
megamcloud / socket.c
Created July 29, 2018 19:00 — forked from nolim1t/socket.c
HTTP Request in C using low level write to socket functionality
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
@megamcloud
megamcloud / wget
Created July 26, 2018 10:59 — forked from bueckl/wget
Wget examples
#Spider Websites with Wget – 20 Practical Examples
Wget is extremely powerful, but like with most other command line programs, the plethora of options it supports can be intimidating to new users. Thus what we have here are a collection of wget commands that you can use to accomplish common tasks from downloading single files to mirroring entire websites. It will help if you can read through the wget manual but for the busy souls, these commands are ready to execute.
1. Download a single file from the Internet
wget http://example.com/file.iso
2. Download a file but save it locally under a different name
wget ‐‐output-document=filename.html example.com
@megamcloud
megamcloud / while_for_syntax_bash.sh
Created July 26, 2018 10:43 — forked from bench/while_for_syntax_bash.sh
while and for loop syntax in bash
# While loop
while [ $i -lt 10 ];
do
[...]
done
# C style for loop
for (( c=1; c<=$MAX_VAL; c++ ))
do
[...]