Skip to content

Instantly share code, notes, and snippets.

View saidsef's full-sized avatar
👻
Building stuff

Said Sef saidsef

👻
Building stuff
View GitHub Profile
@saidsef
saidsef / lambda_cpu_cores.md
Last active February 13, 2024 13:57
AWS Lambda CPU Cores
@saidsef
saidsef / gitlab-container-scanning.md
Last active January 2, 2023 13:27
Container Security: GitLab Trivy Container Scanning

A Simple and Comprehensive Vulnerability Scanner for Containers, Suitable for CI.

It is considered to be used in CI. Before pushing to a container registry, you can scan your local container image easily.

Most of my Docker images are Alpine based. Trivy uses better vulnerability data for Alpine compared to Clair.

This can be easily plugged in to you CI/CD pipeline - in the scenario we we allow the pipeline to fail, the objective here is to provide visibility.

@saidsef
saidsef / git_remove_file.md
Created August 28, 2022 19:52
Git remove file from repo and history

To remove a file from the current commit or HEAD but if you want remove entirely from the repository’s history then you need to run couple of commands.

git filter-branch --index-filter \
    'git rm -rf --cached --ignore-unmatch path_to_file' HEAD

This will rewrite your git history to remove the file

# Prerequisites:
# 1. You must have deployed K8s Spinnaker CRDs
# 2. You must have deployed K8s Operator
---
apiVersion: spinnaker.io/v1alpha2
kind: SpinnakerService
metadata:
name: spinnaker
spec:
spinnakerConfig:
#!/bin/sh
## MIT License - Copyright (c) 2020 - Said Sef
## This script assumes FFMPEG and it's ancillary re installed
## This will encode directory of images into a video
## args: sh ffmpeg-images-to-video.sh *.jpg video-name
ffmpeg -f image2 \
-r 30 \
-pattern_type glob \
-i "$1" \
---
apiVersion: install.istio.io/v1alpha1
kind: IstioOperator
metadata:
namespace: istio-system
name: controlplane
spec:
addonComponents:
istiocoredns:
enabled: false
@saidsef
saidsef / readme.md
Last active December 12, 2020 19:56
AWS Lambda A/B/Canary Routing

For A/B canary routing via AWS CLI

Canary

Canary detects potential bugs and disruption without affecting every other system running. Canary releases are typically short-lived and used to validate whether a release meets the requirements it set out to.

Canary deployment is relatively straightforward, but there are a lot of nuances in how we should approach deploying software this way. Often, we must know ahead of time that we’ll be canary releasing.

Canary deployments have a cost and they add complexity to our processes and our systems. The approach also presents challenges for supporting our product as we have customers with issues on a number of differing versions of the software.

@saidsef
saidsef / meminfo.py
Last active October 8, 2020 08:51
Get total physical memory in Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Said Sef. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
class Meminfo(object):
def __init__(self):
''' Initialize Meminfo class '''
## replace Dockerfile.jetty in https://github.com/plantuml/plantuml-server
## this will produce smaller image ~ 150MB
FROM maven:3-jdk-8 AS builder
RUN apt-get update && \
apt-get install -y --no-install-recommends graphviz fonts-wqy-zenhei && \
apt-get clean
COPY pom.xml /app/
#!/bin/bash
#
# This script will attempt to detect any ephemeral drives on an EC2 node and create a RAID-0 stripe
# mounted at /mnt. It should be run early on the first boot of the system.
set -exo pipefail
METADATA_URL_BASE="http://169.254.169.254/2012-01-12"
# Configure Raid - take into account xvdb or sdb
root_drive=`df -h | grep -v grep | awk 'NR==4{print $1}'`