Skip to content

Instantly share code, notes, and snippets.

View 0xMH's full-sized avatar
💤

Hamza 0xMH

💤
View GitHub Profile
@0xMH
0xMH / aws-transfer-sftp.yaml
Created October 24, 2022 09:21 — forked from glnds/aws-transfer-sftp.yaml
CloudFormation template for AWS Transfer for SFTP
---
AWSTemplateFormatVersion: '2010-09-09'
Description: some-sftp-server
Parameters:
HostedZoneIdParam:
Type: String
Description: Hosted Zone ID
SFTPHostnameParam:
Type: String
@0xMH
0xMH / README.md
Created October 6, 2022 09:53 — forked from nikoheikkila/README.md
Fish Shell function for sourcing standard .env files

envsource

I've been using Fish shell for years which is great and all, but one thing that has got me frustrated is using it with .env files.

When attempting to run source .env in a project, I usually encounter this problem:

.env (line 2): Unsupported use of '='. In fish, please use 'set KEY value'.
from sourcing file .env
source: Error while reading file '.env'
@0xMH
0xMH / README.md
Last active May 21, 2020 21:07
Migration of Kubernetes cluster deployment state

Migration of Kubernetes cluster deployment state

The deployment state of the Kubernetes cluster is stored in etcd. If you're concerned about backing up this information, you should look into backing up the etcd data directory for each etcd instance in your cluster. This can be done via an etcd-based backup strategy, or via snapshotting the underlying block device that backs the etcd data directory. Backing up Kubernetes clusters is not the purpose of this document.

This document's primary purpose is to show how to migrate the deployment state from one Kubernetes cluster to another. The clusters may have different versions, pod/service network cidrs, number of nodes, etc.

For the remainder of this document, the cluster that is being dumped will be referred to as the source cluster. The cluster that is being restored to will be called the target cluster. The goal is to migrate state from the source cluster to the *ta

@0xMH
0xMH / HOVPN.md
Last active September 20, 2018 17:32
Highly Available / Fault Tolerant VPN Cluster

Imgur

To achieve this, I built out a cluster of hosts using Amazon's EC2 Container Service and run multiple standalone OpenVPN containers in an Auto-scaling group on each host, ensuring high availability. An Elastic Load Balancer routes traffic to the hosts, which then redirect traffic to the appropriate containers. I created a mounted volume on both of my ECS Nodes which utilizes Elastic Filesystem to store configuration files for my OpenVPN containers ensuring there is no duplication of data between the various containers. And....is it fast? You betcha! From the time ECS recognizes there has been a failure with one of the containers, a new one is up and running within 5 seconds.

https://hub.docker.com/r/kylemanna/openvpn/

@0xMH
0xMH / AWS.txt
Last active August 9, 2018 14:51
AWS CUT Costs
Dears,
I went through our AWS account specially the 2-instances xxx.xxx.com and ooo.ooo.com,
Here’s what I noticed and what can be done to reduce the cost.
First:
For the “xxx.xxx.com”
Instance type: On-Demand c4.large
We pay approximately $75/month for it.
/**
* Authentication
* @namespace thinkster.authentication.services
* Make a file in static/javascripts/authentication/services/ called authentication.service.js
*/
(function () {
'use strict';
angular
@0xMH
0xMH / deploy.sh
Created April 27, 2018 17:43 — forked from kcabading/deploy.sh
Bash script for deploying Wordpress using Jenkins and Bitbucket.
#!/bin/bash
# PLACEHOLDERS
# [STAGING_FOLDER] - staging directory in your server
# [STAGING_URL] - staging url
# [STAGING_USER] - staging user in the server
# [STAGING_MYSQLUSER] - staging mysql user
# [STAGING_MYSQLPASSWORD] - staging mysql password
# [ROOTUSER] - Mysql root user
# [ROOTPASSWORD] - Mysql root password
@0xMH
0xMH / downloadXkcd
Created July 8, 2017 10:09
downloadXkcd.py - Downloads every single XKCD comic.
#! python3
# downloadXkcd.py - Downloads every single XKCD comic.
# source: Automated the Boring Stuff with Python
import requests, os, bs4
url = 'http://xkcd.com' # starting url
os.makedirs('xkcd', exist_ok=True) # store comics in ./xkcd
while not url.endswith('#'):
# Download the page.
print('Downloading page %s...' % url)