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 / grafana-cloud-k8s.yaml
Created June 23, 2023 04:35
Grafana Cloud integration with Kubernetes
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: grafana-agent
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
@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
@safoorsafdar
safoorsafdar / Chart.yaml
Last active May 4, 2022 02:04
Example Helm chart for the Mendix application
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for mxchart Application
name: mxchart
version: 0.1.1
# 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 / gitlab-ci.yaml
Created April 24, 2022 22:57
Deploy Mendix apps to Kubernetes with Gitlab
image: alpine
stages:
- build
- publish
- deploy
- clean
variables:
MENDIX_BUILD_PATH: mxsrc
MENDIX_BUILDPACK_VERSION: v3.6.4
@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({
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "StackStorm API",
"description": "\n## Welcome\n\nWelcome to the StackStorm API Reference documentation! You can use the StackStorm API to integrate StackStorm with 3rd-party systems and custom applications. Example integrations include writing your own self-service user portal, or integrating with other orquestation systems.\n\nThis document provides an overview of how to use the API. Use the menu on the left to look up details of specific API endpoints. For more information about how StackStorm works, and how to use it, check out the main [StackStorm documentation](https://docs.stackstorm.com).\n\n> ### A Quick Note\n> This API is intended for software developers, and those are who are comfortable working with RESTful APIs, and writing some code. You do not need to use this API to work with StackStorm, or to use and write integration packs for StackStorm.\n\n## Accessing the API\n\nUsually the API is available at `https://$ST2_HOSTN
@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 / centos-6-service.sh
Last active March 6, 2020 15:00
Amazon Linux or CentOS 6 or RHEL 6 Service for Prometheus Node Exporter
#!/bin/sh
#
# example start stop daemon for CentOS (sysvinit)
#
# chkconfig: - 64 36
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 2 3 4 6
# Required-Start:
# description: node_exporter start stop daemon for CentOS