Skip to content

Instantly share code, notes, and snippets.

View 76creates's full-sized avatar
🤔
breaking your repo

Dusan Gligoric 76creates

🤔
breaking your repo
View GitHub Profile
### Keybase proof
I hereby claim:
* I am 76creates on github.
* I am 76creates (https://keybase.io/76creates) on keybase.
* I have a public key ASBhc_Ur9atjMnsbDFONVKYTsJu90f62NwnGEW7rDopLiAo
To claim this, I am signing this object:
@76creates
76creates / aws_monthly_ec2_infra_cost.bash
Created June 13, 2022 14:00
Calculate on-demand EC2 cost of captured instances
# This was initially created to calculate the cost of the static infrastructure only
# excluding some instance which were dynamic, you can use this to calculate your
# instance cost per month and to date cost filtered by regex expression, it does this
# for your instances region thus is precise when it comes to cost, tho it uses curent
# cost and does not have historical cost data
# INSTANCE_RE regex with which we filter instances of interest
INSTANCE_RE='^[0-9a-z]{8}-([0-9a-z]{4}-){3}'
# INSTANCE_RE_INVERT set to '.' if you want to match regualar, and to 'not' if you want to inverse regex capture
INSTANCE_RE_INVERT='not'
@76creates
76creates / main.go
Created February 22, 2022 23:07
charmbracelet/lipgloss sample code for #69
package main
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"os"
)
type m struct {
s lipgloss.Style
@76creates
76creates / kube-context-switch.sh
Last active January 11, 2022 11:48
cycle up/down kubectl context
kd () {
kubectl config use-context $(
kubectl config get-contexts | awk 'NR == 2 { first=$1 } { if ($1 == "*") { if(getline == 1) { print $2 } else { print first }}}'
)
}
ku () {
kubectl config use-context $(
kubectl config get-contexts | awk 'BEGIN {previous=0} NR>1 { { if ($1 == "*") { if (previous!=0) {print previous} else { while (getline == 1){} print $2 } } } { previous=$2 } }'
)
}
@76creates
76creates / gist:3d07d336e9a3f5256ffe3de9b23d9790
Created March 26, 2020 12:06
golang 302 redirection and order of things in response
// in order to do a redirection or any response including custom code/header/json body at the same time
// order in which they are arranged is important, one will overwrite another and you wont get proper
// response, bellow is the order which will allow you to set all 3
// any custom header goes first
w.Header().Set(
"Location",
"http://localhost/something/else
)
@76creates
76creates / python_curses_overlay_windows.py
Last active January 21, 2022 04:56
Python curses overlaying windows
'''
If you ever wondered how overlaying works in python curses lib so did I! This is how it works:
'''
import curses
def start(stdscr):
# sets up no delay so keys dont overload CPU
stdscr.nodelay(False)
# no blinking cursor
URL match >
^https?:\/\/([\w\-]+\.)+[a-z]+(\.[a-z]+)?(\/[\w_\-#\.%]+)*?\/?(\?(\w+\=[^&]+(\&\w+\=[^&]+)*))?[^\.]$
@76creates
76creates / nginx_gunicorn.sh
Last active January 24, 2018 17:40
Centos7 Nginx + Gunicorn
yum -y install epel-release
yum -y update
yum -y install nginx
# INSTALLING PYTHON 3.6
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
yum -y install python36u python36u-pip python36u-devel python36u-setuptools
# SETTING UP IPTABLES
iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT