Skip to content

Instantly share code, notes, and snippets.

@mhewedy
mhewedy / download_openjdk<version>.sh
Last active October 31, 2020 23:23
Download latest release of openjdk 15 from jdk.java.net
wget -O openjdk-15.tar.gz $(curl -s https://jdk.java.net/15/ | gawk 'match($0, "http.*openjdk-15.*linux-x64_bin.tar.gz", ary) {print ary[0]}' | uniq)
@mhewedy
mhewedy / k8s_alerting.sh
Created October 3, 2020 18:52
Report k8s jobs running for long time
# report jobs is running for more than 60 minutes
sudo kubectl get pods -l job-name -o jsonpath='{range .items[*]}{.metadata.name}{" "}{.status.phase}{" "}{.status.startTime}{"\n"}{end}' | while read line; do
name=$(echo $line | awk '{print $1}')
phase=$(echo $line | awk '{print $2}')
startTime=$(echo $line | awk '{print $3}')
now=$(date +%s)
start=$(date -d $startTime +"%s")
diff=$(( ($now - $start)/60 ))
@mhewedy
mhewedy / README.md
Last active September 30, 2020 15:19
Make release

Usage:

$ mkrel path/to/release
2.02.159

To see the whole list in debug mode, define a DEBUG env var and set it to 1:

package main
import (
"context"
"database/sql"
"fmt"
"github.com/Fs02/rel"
"github.com/Fs02/rel/adapter/postgres"
"github.com/jackc/pgx/v4"
pgxs "github.com/jackc/pgx/v4/stdlib"
@mhewedy
mhewedy / curl
Created August 24, 2020 20:39
my curl
/usr/bin/curl -s -H "content-type: application/json" $(echo " "$@ | perl -pe 's/\s+(:[0-9]+)/localhost$1/g') | jq
package main
import (
"encoding/json"
"fmt"
"log"
"net/http"
"strings"
"time"
)
@mhewedy
mhewedy / iptv.go
Created May 30, 2020 04:36
group ip tv
package main
import (
"fmt"
"io/ioutil"
"os"
"regexp"
"sort"
"strings"
)
# worker.sh
# find most updated version at: https://github.com/mhewedy/vermin/tree/master/etc/samples-provision/k8s
# HW requirements: 1 CPUS 2 RAM
# OS: Ubuntu focal
set -ex
#should be $(lsb_release -cs) but it appears it is not working on focal yet
docker_ubuntu_release=bionic
k8s_version=1.18.0
# master.sh
# find most updated version at: https://github.com/mhewedy/vermin/tree/master/etc/samples-provision/k8s
# HW requirements: 2 CPUS 2 RAM
# OS: Ubuntu focal
set -ex
#should be $(lsb_release -cs) but it appears it is not working on focal yet
docker_ubuntu_release=bionic
k8s_version=1.18.0
@mhewedy
mhewedy / defer.go
Created May 7, 2020 11:30
Defer trick to around wrap function code
package main
import (
"fmt"
)
type Tnx struct {
}
func main() {