Skip to content

Instantly share code, notes, and snippets.

View stafot's full-sized avatar
🐧

Stavros Foteinopoulos stafot

🐧
View GitHub Profile
@stafot
stafot / reset_virtualbox_dhcp_leases.sh
Last active November 3, 2020 11:15
Resets virtualbox DHCP leases to ensure that minikube will always take a specific IP.
#!/usr/bin/env bash
function minikube_reset_vbox_dhcp_leases() {
# Check OS version
case $OSTYPE in
darwin*)
VBOX_CONFIG_DIR=Library
;;
linux*)
@stafot
stafot / README.md
Created May 24, 2019 14:16 — forked from iMilnb/README.md
AWS Terraform configuration: Stream CloudWatch Logs to ElasticSearch

Rationale

This snippet is a sample showing how to implement CloudWatch Logs streaming to ElasticSearch using terraform. I wrote this gist because I didn't found a clear, end-to-end example on how to achieve this task. In particular, I understood the resource "aws_lambda_permission" "cloudwatch_allow" part by reading a couple of bug reports plus this stackoverflow post.

The js file is actually the Lambda function automatically created by AWS when creating this pipeline through the web console. I only added a endpoint variable handling so it is configurable from terraform.

@stafot
stafot / open-pr
Created February 21, 2019 19:48 — forked from garno/open-pr
Small bash script to automatically open Pull Request page with branches correctly selected
#!/bin/sh
# Retrieve branch name
branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
# Retrieve destination branch
destination_branch=${branch%--*}
# Determine the default origin branch
if [[ $branch == $destination_branch ]]; then
@stafot
stafot / gpr.sh
Created December 28, 2018 15:18 — forked from dwmkerr/gpr.sh
A shell command to push and open a pull request. Tested on OSX/Ubuntu. No dependencies.
#!/usr/bin/env bash
# gpr - push the current branch to origin and attempt to open the Create Pull
# Request or Create Merge Request page if available.
#
# Inspired by: https://gist.github.com/tobiasbueschel/ba385f25432c6b75f63f31eb2edf77b5
# How to get the current branch: https://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch
# How to open the browser: https://stackoverflow.com/questions/3124556/clean-way-to-launch-the-web-browser-from-shell-script
# Colour constants for nicer output.
GREEN='\033[0;32m'
@stafot
stafot / k8s-patch.go
Created December 28, 2018 15:16 — forked from dwmkerr/k8s-patch.go
Example showing how to patch Kubernetes resources in Golang. Companion to the article 'https://dwmkerr.com/patching-kubernetes-resources-in-golang/'.
// Example showing how to patch kubernetes resources.
// This is the companion to my article 'Patching Kubernetes Resources in Golang':
// https://dwmkerr.com/patching-kubernetes-resources-in-golang/
package main
import (
"encoding/json"
"fmt"
types "k8s.io/apimachinery/pkg/types"
@stafot
stafot / sort_time.go
Created December 5, 2018 11:23 — forked from xigang/sort_time.go
Sorting by time.Time in Golang
package main
import (
"fmt"
"sort"
"time"
)
type reviews_data struct {
review_id string
@stafot
stafot / index.md
Created October 22, 2018 11:45 — forked from bvaughn/index.md
How to use profiling in production mode for react-dom
@stafot
stafot / k8s-svc-annotations.md
Created October 15, 2018 08:54 — forked from mgoodness/k8s-svc-annotations.md
AWS ELB-related annotations for Kubernetes Services (as of v1.12.0)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-emit-interval (in minutes)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-enabled (true|false)
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-name
  • service.beta.kubernetes.io/aws-load-balancer-access-log-s3-bucket-prefix
  • service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags (comma-separated list of key=value)
  • service.beta.kubernetes.io/aws-load-balancer-backend-protocol (http|https|ssl|tcp)
  • service.beta.kubernetes.io/aws-load-balancer-connection-draining-enabled (true|false)
@stafot
stafot / cli-fu.md
Created July 8, 2018 05:45 — forked from mhausenblas/cli-fu.md
Michael's bash snippets
@stafot
stafot / emojis.js
Created January 28, 2018 08:17 — forked from thisisshi/emojis.js
Quick and Dirty Emoji Export from Slack
// Go to: https://<team>.slack.com/customize/emoji
// Open Developer Console
// Copy/Paste and Run this in the console:
var spans = document.getElementsByTagName('span');
var basharray = "( "
for (var i=0;i<spans.length;i++) {
var link = spans[i].getAttribute("data-original");
if(link != null){
basharray = basharray.concat(link, " ")