Skip to content

Instantly share code, notes, and snippets.

View devypt's full-sized avatar
🎯
Focusing

Ahmed Mohamed devypt

🎯
Focusing
  • Tradeling.com
  • Dubai
  • 11:10 (UTC -12:00)
View GitHub Profile
@devypt
devypt / email.go
Created September 15, 2019 11:59 — forked from carelvwyk/email.go
Building an email in Golang to be delivered using Amazon SES
func buildEmailInput(source, destination, subject, message string,
csvFile []byte) (*ses.SendRawEmailInput, error) {
buf := new(bytes.Buffer)
writer := multipart.NewWriter(buf)
// email main header:
h := make(textproto.MIMEHeader)
h.Set("From", source)
@devypt
devypt / benchmark+go+nginx.md
Created May 20, 2018 03: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
@devypt
devypt / cart
Created December 20, 2017 08:06
{
"createdAt": "2017-12-20 06:13:11",
"updatedAt": "2017-12-20 06:13:31",
"status": 10,
"trackId": "e1a2ab6c-aea7-4fba-af02-0608d1f5abdc",
"customerId": "",
"storeId": 58,
"groupId": 2,
"products": [
{
@devypt
devypt / ip2country.php
Created October 17, 2017 13:37
ip2country, get ip country
<?php
/*
* This script will get country codes for a list of ips
*/
$url = 'http://ip2country.hackers.lv/api/ip2country?ip=';
$ips = ['11.12.13.14'];
unlink('ip-country.csv');
$file = fopen("ip-country.csv", "w") or die("Unable to open file!");
@devypt
devypt / docker.sh
Created October 9, 2017 13:09
Docker Remove Every thing, containers, images, volumes
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker container prune
# Delete all volumes
docker volume prune
@devypt
devypt / statistics
Created September 5, 2017 12:50 — forked from AlaaAttyaMohamed/statistics
calculate request times
#!/bin/bash
# defone globals
LOOP_COUNT=20
QUOTE_API_BASE_URL=https://lite.uat.travelguard.com/sml
TIME_NAME_LOOKUP=0
TIME_APP_CONNECT=0
TIME_CONNECT=0
TIME_REDIRECT=0
@devypt
devypt / disable-vagrant-time-sync.sh
Created March 14, 2016 10:49 — forked from X0nic/disable-vagrant-time-sync.sh
Disable vagrant time sync
#List vms
VBoxManage list vms
#get status of time sync
VBoxManage getextradata <vm-name> VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled
#NOTE: Make sure to restart the VM after changing these settings.
#disable time sync
VBoxManage setextradata <vm-name> VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled 1
@devypt
devypt / docker-machine-mac-osx.md
Created October 14, 2015 12:53 — forked from Integralist/docker-machine-mac-osx.md
Docker Machine on Mac OS X
  • https://www.docker.com/toolbox
  • docker-machine create --driver virtualbox dev
  • docker-machine env dev (add values to ~/.zshrc)
    • e.g. echo eval "$(docker-machine env dev)" >> ~/.zshrc
  • docker-machine ls
  • docker ps (might need to re-source .zshrc file; e.g. . ~/.zshrc)
  • docker run hello-world
  • docker-machine ip dev
  • docker-machine stop dev
  • docker-machine start dev
sudo mount.vboxsf -o fmode=777,dmode=777,uid=1000,gid=1000 /sharename /vagrant