Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View themegabyte's full-sized avatar

Shayan themegabyte

View GitHub Profile
@themegabyte
themegabyte / reclaim-resize-expand.md
Created April 2, 2024 14:25
Reclaiming disk space from SWAP or Expanding once it has been increased from VMWARE.
#!/usr/local/bin/bash
# pkg install bash
# add to shellcmd as "/root/push_ip_metrics.sh &" via Services/shellcmd
pushgatewayip="192.168.1.2:9091"
network="192.168.1.0/24"
interface="bce1"
interval="1"
rate -i "${interface}" -r "${interval}" -e -n -Ab -a 255 -c "${network}" -d | while read -r line; do
@themegabyte
themegabyte / node_exporter.sh
Created February 26, 2024 20:33 — forked from galexrt/node_exporter.sh
Simple Prometheus node_exporter install script (Updated for 1.0.1)
#!/bin/bash
version="${VERSION:-1.0.1}"
arch="${ARCH:-linux-amd64}"
bin_dir="${BIN_DIR:-/usr/local/bin}"
wget "https://github.com/prometheus/node_exporter/releases/download/v$version/node_exporter-$version.$arch.tar.gz" \
-O /tmp/node_exporter.tar.gz
mkdir -p /tmp/node_exporter
@themegabyte
themegabyte / replace-apt-mirror.md
Created October 18, 2023 15:03 — forked from yusufhm/replace-apt-mirror.md
replace default apt with au mirror using Vim or sed
@themegabyte
themegabyte / keybindings.json
Created August 27, 2023 21:22
This JSON keybinding configuration sets up a key combination (Ctrl+Shift+L) to insert a snippet that creates a console.log statement containing the selected text, if any, alongside its value, in a VSCODE
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+shift+l",
"command": "editor.action.insertSnippet",
"when": "editorTextFocus",
"args": {
"snippet": "console.log(\"${TM_SELECTED_TEXT}\", ${TM_SELECTED_TEXT});"
}
}
@themegabyte
themegabyte / 01-multistage-build.sh
Created July 11, 2023 06:33 — forked from evadne/01-multistage-build.sh
Build & Cache multi-stage Docker images (with Build Specification for AWS CodeBuild)
# the general idea
ImageTag="git"
FilePath="/Dockerfile"
RepoURI="123456789012.dkr.ecr.eu-west-1.amazonaws.com/repo"
Stages=$(cat $FilePath | grep -oP '^FROM .+ (AS|as) \K(.+)$')
CacheArgs=$(for Stage in $Stages; do echo "--cache-from $RepoURI:cache-$Stage"; done | paste -sd ' ')
BuildArgs="--file $FilePath $CacheArgs"
for Stage in $Stages; do docker pull $RepoURI:cache-$Stage || true; done
for Stage in $Stages; do docker build $BuildArgs --tag $RepoURI:cache-$Stage --target $Stage . || break; done
docker build $BuildArgs --tag $RepoURI:$ImageTag .
@themegabyte
themegabyte / commands.sh
Last active June 27, 2023 10:10
AWS SSM Migration
aws ssm get-parameters-by-path --recursive --path "/CodeBuild/" --max-items 100
@themegabyte
themegabyte / directus.js
Created June 4, 2023 18:53
Directus SDK with Axios Interceptors.
import { Directus } from "@directus/sdk";
const DIRECTUS_ENDPOINT = process.env.DIRECTUS_HOST || "";
const DIRECTUS_TOKEN = process.env.DIRECTUS_TOKEN || "";
const directus = new Directus(DIRECTUS_ENDPOINT, {
auth: {
staticToken: DIRECTUS_TOKEN,
},
});
@themegabyte
themegabyte / .drone.yml
Created March 26, 2023 19:16
my drone CI config with Minio as Cache.
---
kind: pipeline
type: docker
name: default
steps:
- name: ubuntu-ls
image: ubuntu
commands:
- ls -la
@themegabyte
themegabyte / NumberComponent.jsx
Created March 24, 2023 17:35
React Number Component.
export const NumberComponent = (props) => {
const [myVal, setMyVal] = useState(props.value);
// update myVal if props.value changes on a rerender. useState only updates on initial render
if (myVal != props.value) setMyVal(props.value);
const onValChange = (e) => {
const { value, validity } = e.target;
if (myVal != props.value) setMyVal(props.value);
else setMyVal(value);
if (validity.valid) props.onChangeFunction(e);
};