Skip to content

Instantly share code, notes, and snippets.

View safoorsafdar's full-sized avatar
:shipit:
Working from Home

Safoor Safdar safoorsafdar

:shipit:
Working from Home
View GitHub Profile
@safoorsafdar
safoorsafdar / gcp-aws-site-to-site-vpn.sh
Created May 2, 2023 16:42 — forked from mikesparr/gcp-aws-site-to-site-vpn.sh
Example site to site VPN between Google Cloud Platform (GCP) and Amazon Web Services (AWS)
#!/usr/bin/env bash
#####################################################################
# REFERENCES
# - https://cloud.google.com/architecture/build-ha-vpn-connections-google-cloud-aws
# - https://cloud.google.com/vpc/docs/private-service-connect
#####################################################################
export PROJECT_ID=$(gcloud config get-value project)
export PROJECT_USER=$(gcloud config get-value core/account) # set current user
# get total requests by status code
awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
# get top requesters by IP
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head | awk -v OFS='\t' '{"host " $2 | getline ip; print $0, ip}'
# get top requesters by user agent
awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
# get top requests by URL
@safoorsafdar
safoorsafdar / php-pools.md
Created July 26, 2021 18:46 — forked from holmberd/php-pools.md
Adjusting child processes for PHP-FPM (Nginx)

Adjusting child processes for PHP-FPM (Nginx)

When setting these options consider the following:

  • How long is your average request?
  • What is the maximum number of simultaneous visitors the site(s) get?
  • How much memory on average does each child process consume?

Determine if the max_children limit has been reached.

  • sudo grep max_children /var/log/php?.?-fpm.log.1 /var/log/php?.?-fpm.log
@safoorsafdar
safoorsafdar / livestream.component.ts
Created January 20, 2021 13:44 — forked from shah-smit/livestream.component.ts
Angular 4, Live Streaming
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Router } from '@angular/router';
import { LoginService, AzureService } from '../services'
import { User, LiveSession } from '../models'
import { SharedService } from "app/services/shared.service";
//declare var SimpleWebRTC;
declare var io;
declare var conference;
@Component({
@safoorsafdar
safoorsafdar / benchmark_redis.go
Created September 29, 2020 15:32 — forked from AhmadElsagheer/benchmark_redis.go
Redis mget vs hget with keys sharing prefix
package benchmark
// Processor: Intel® Core™ i3-2348M CPU @ 2.30GHz × 4
// Memory: 5.7 GiB
//
// Benchmarking on 100,000 records
// - record key length = 50
// - length of common key (prefix) among all records = 15
// - record value length = 5
//
@safoorsafdar
safoorsafdar / gist:b943f1dfdb218b7f41bc3df035717971
Created July 10, 2019 12:04 — forked from mtigas/gist:952344
Mini tutorial for configuring client-side SSL certificates.

Client-side SSL

For excessively paranoid client authentication.


Updated Apr 5 2019:

because this is a gist from 2011 that people stumble into and maybe you should AES instead of 3DES in the year of our lord 2019.

some other notes:

@safoorsafdar
safoorsafdar / git-maintenance.sh
Last active December 28, 2016 16:09 — forked from Zoramite/maintenance.sh
Git Maintenance Commands
# Verifies the connectivity and validity of the objects in the database
git fsck --unreachable
# Manage reflog information
git reflog expire --expire=0 --all
# Pack unpacked objects in a repository
git repack -a -d -l
# Prune all unreachable objects from the object database
#!/bin/bash
# from https://www.howtoforge.com/tutorial/vagrant-ubuntu-linux-apache-mysql-php-lamp/
# Update Repo
sudo apt-get -y update
# Install Apache
sudo apt-get -y install apache2
# Install MySQL