Skip to content

Instantly share code, notes, and snippets.

View megamcloud's full-sized avatar

Megam.Cloud megamcloud

View GitHub Profile
@megamcloud
megamcloud / ca.md
Created April 29, 2018 16:42 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@megamcloud
megamcloud / cloud_acronyms.md
Created July 26, 2018 10:43 — forked from bench/cloud_acronyms.md
Cloud computing acronyms
  • IAAS (infrastructure as a service) : Permet de monter des machines, c'est de la VM, de l'automatisation. On déplacait l'infrastructure.
  • CAAS (container as a service) : Virtualisation non plus par VM mais par containers tel que Docker. Les fournisseurs peuvent fournir des plateformes d'orchestration dont Google Kubernetes ou Docker Swarm. PAAS (platform as a service) : google app engine, amazon S3, etc, ce sont des sevices managés
  • BAAS (backend as a service) : Ce n'est pas un service de cloud mais un concept d'architecture qui fournit l'authentification, la scalabilité automatique, et des services tels que les push notifications pour le développement d'app mobile.
  • FAAS (functions as a service) : La plate-forme qui instancie à la volée une fonction lors d'un appel d'API. On ne paie plus en nombre de machine ou autre mais au nombre d'appels d'API
@megamcloud
megamcloud / condition_syntax_bash.sh
Created July 26, 2018 10:43 — forked from bench/condition_syntax_bash.sh
conditions syntax in bash
## check the return of a command
if command; then
[...]
fi
## check by string comparison / numerical / file existence / or more
if [[ CHECK ]]; then
[...]
fi
@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
[...]
@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 / 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 / benchmark+go+nginx.md
Created July 30, 2018 07:31
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 / 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 / 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 / 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