Skip to content

Instantly share code, notes, and snippets.

View Clivern's full-sized avatar

Ahmed Clivern

View GitHub Profile
@Clivern
Clivern / nginxproxy.md
Created May 12, 2018 14:45 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@Clivern
Clivern / rabbitmq.sh
Last active June 25, 2018 08:39
Run RabbitMQ on Docker
# Docker
docker pull rabbitmq
docker run -d --hostname my-rabbit --name some-rabbit -p 4369:4369 -p 5671:5671 -p 5672:5672 -p 15672:15672 rabbitmq
docker exec some-rabbit rabbitmq-plugins enable rabbitmq_management
# Login at http://localhost:15672/ (or the IP of your docker host)
# using guest/guest
@Clivern
Clivern / php7.1_ubuntu16.04.sh
Created August 9, 2018 15:27
Install PHP7.1 on Ubuntu 16.04
#! /bin/bash
sudo apt-get install -y software-properties-common python-software-properties
# 1. Add Ondrejs PPA Repo and update
echo "$(tput setaf 2)1. Add Ondrejs PPA Repo and update...$(tput sgr 0)"
sudo add-apt-repository ppa:ondrej/php -y -u
# 2. Remove default PHP 7.0
echo "$(tput setaf 2)2. Update PHP to latest$(tput sgr 0)"
@Clivern
Clivern / vault-install.sh
Created August 29, 2018 20:22 — forked from ewilde/vault-install.sh
Install hashicorp vault on ubuntu using systemd
#!/usr/bin/env bash
set -e
echo "Installing dependencies..."
sudo apt-get update -y
sudo apt-get install -y unzip
echo "Fetching vault..."
VAULT=0.6.5
@Clivern
Clivern / gist:742f511e8554b1510c9139a1ecaf1dc4
Created October 1, 2018 16:27
An example of a JSON Unmarshal into a Go struct.
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type Artist struct {
@Clivern
Clivern / handler.go
Created October 2, 2018 12:39 — forked from rjz/handler.go
Handle Github webhooks with golang
// Now available in package form at https://github.com/rjz/githubhook
package handler
// https://developer.github.com/webhooks/
import (
"crypto/hmac"
"crypto/sha1"
"encoding/hex"
"errors"
@Clivern
Clivern / upgrade_to_symfony3-lts.md
Created January 29, 2019 14:18 — forked from mickaelandrieu/upgrade_to_symfony3-lts.md
Migration guide to Symfony 3 LTS

Let's migrate a Symfony 2.8 LTS application to Symfony 3 LTS

Handle deprecations

First of all, ensure you don't have any deprecated!

The Symfony documentation explains it well, but let's sum up:

  • install the phpunit bridge ($ composer require --dev symfony/phpunit-bridge)
  • also check all your pages using web profiler and be ensure there is no deprecation error handled
  • found errors and need help about how to fix it ? I did a sort of guide.
@Clivern
Clivern / upgrade2.3-to-2.7.md
Created January 29, 2019 14:31 — forked from mickaelandrieu/upgrade2.3-to-2.7.md
Complete migration guide from Symfony 2.3 LTS to Symfony 2.7 LTS

From Symfony 2.3 to Symfony 2.7: the complete guide

Objectives

  • assume your code doesn't use any deprecated from versions below Symfony 2.3
  • update dependencies from 2.3 to 2.7
  • do not support "deprecated", be "Symfony3-ready"
  • list tasks component by component, bundle by bundle.

A lack of memory or swap, or not having swap configured

$ sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
$ sudo /sbin/mkswap /var/swap.1
$ sudo /sbin/swapon /var/swap.1
@Clivern
Clivern / py_tz_aware.py
Created April 12, 2019 11:08
Change Python Datetime to Timezone Aware
import datetime
import pytz
unaware = datetime.datetime(2019, 8, 15, 8, 15, 12, 0)
aware = datetime.datetime(2019, 8, 15, 8, 15, 12, 0, pytz.UTC)
now_aware = unaware.replace(tzinfo=pytz.UTC)
assert aware == now_aware