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 / 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

#!/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" \
# 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:
---
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 / 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 / ml-algorithms-laymans-terms.md
Last active April 3, 2020 14:59
Machine Learning Algorithms In Layman’s Terms

I’ll be going over:

  • Gradient Descent / Line of Best Fit
  • Linear Regression
  • Ridge & LASSO Regression
  • Logistic Regression
  • Decision Trees
  • Random Forest

“a model is like a Vending Machine, which given an input (money), will give you some output (a soda can maybe) . . . An algorithm is what is used to train a model, all the decisions a model is supposed to take based on the given input, to give an expected output. For example, an algorithm will decide based on the dollar value of the money given, and the product you chose, whether the money is enough or not, how much balance you are supposed to get [back], and so on.”

@saidsef
saidsef / pod-spec.yml
Created July 10, 2019 13:58
Pod ENV Values from K8s API
spec:
containers:
- env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_NODE_IP
valueFrom:
fieldRef:
#!/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}'`
#!/bin/bash
set -euo pipefail
MICROSCANNER_TOKEN="${MICROSCANNER_TOKEN:-}"
MICROSCANNER_OPTIONS="${MICROSCANNER_OPTIONS:-}"
DOCKER_IMAGE="${1:-}"
TEMP_IMAGE_TAG=$(LC_CTYPE=C tr -dc 'a-zA-Z0-9' </dev/urandom | fold -w 32 | head -n 1 | tr '[:upper:]' '[:lower:]' || true)
main() {
local MICROSCANNER_BINARY MICROSCANNER_SOURCE