Skip to content

Instantly share code, notes, and snippets.

View imixtron's full-sized avatar
🎯
Focusing

Imad Ali Khan Abbasi imixtron

🎯
Focusing
View GitHub Profile
@imixtron
imixtron / delete-unmounted-pvc.sh
Created August 16, 2020 11:45
Delete unmounted pvc's across cluster
# 👏 https://stackoverflow.com/questions/53202727/how-to-delete-only-unmounted-pvcs-and-pvs#answer-59758937
# List Unmounter PVC's
kubectl describe -A pvc | grep -E "^Name:.*$|^Namespace:.*$|^Mounted By:.*$" |\
grep -B 2 "<none>" | grep -E "^Name:.*$|^Namespace:.*$"
# Delete Unmounted PVC's
kubectl describe -A pvc | grep -E "^Name:.*$|^Namespace:.*$|^Mounted By:.*$" |\
grep -B 2 "<none>" | grep -E "^Name:.*$|^Namespace:.*$" | cut -f2 -d: |\
paste -d " " - - | xargs -n2 bash -c 'kubectl -n ${1} delete pvc ${0}'
@imixtron
imixtron / README-Template.md
Created February 3, 2020 21:08 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@imixtron
imixtron / getRoutes.ts
Created October 22, 2019 14:53
Get all registered routes from express router
// small function to get routes from an express router
// https://stackoverflow.com/questions/14934452/how-to-get-all-registered-routes-in-express#answer-26275395
export function listRoutes(...args: Router[]){
for (var i = 0; i < arguments.length; i++) {
if(arguments[i].stack instanceof Array){
console.log('');
arguments[i].stack.forEach(function(a: any){
var route = a.route;
if(route){
@imixtron
imixtron / loop.sh
Created September 19, 2019 08:22
bash loop array and run command
array=( chg8p p9dzh ); \
loc="/bin/"; \
for i in "${array[@]}"; \
do echo $i; \
mv $i $loc
done
@imixtron
imixtron / k8s_copy_secret.sh
Last active September 17, 2019 06:20
Copy secret between k8s namespaces
#!/bin/bash
kubectl get <resource-type> <resource-name> -n <source-namespace-name> -o yaml |\
sed 's/namespace: <source-namespace-name>/namespace: <target-namespace-name>/' |\
kubectl create -f -
> Example:
kubectl get secret auth-token -n web-dev -o yaml |\
sed 's/namespace: web-dev/namespace: web-qa/' |\
kubectl create -f -
@imixtron
imixtron / gist:6aa077a12ebf9dba3f62c48f8b7e2be3
Created July 17, 2018 10:57 — forked from karlgroves/gist:7544592
Get DOM path of an element
function getDomPath(el) {
var stack = [];
while ( el.parentNode != null ) {
console.log(el.nodeName);
var sibCount = 0;
var sibIndex = 0;
for ( var i = 0; i < el.parentNode.childNodes.length; i++ ) {
var sib = el.parentNode.childNodes[i];
if ( sib.nodeName == el.nodeName ) {
if ( sib === el ) {
/**
* Time Difference takes input in Hours Format
* Author: imixtron
* Accepts: String Values (HH:MM)
* Max: 24:00, Min: 00:00
*
* example timeDifference("10:37","12:35")
*/
timeDifference(from, to) {
@imixtron
imixtron / $helper.JS
Last active September 19, 2019 08:26
Helper functions for angular.js
//server; /api/
var APP_PREFIX = 'pMeds_',
APP_URL = '/api/',
APP_TIMEOUT = 1000 * 30,
HTTP_REQUEST = null,
APP_DATA = {};
APP_FORMAT = 'json';
var API = {
@imixtron
imixtron / mongo_backup.sh
Created March 1, 2017 10:54 — forked from sheharyarn/mongo_backup.sh
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
APP_NAME="your_app_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
//hexaTime.js
//author: imixtron
//Javascript function to return unique hexadecimal string (that i personally use)
function getUniqueKey(){
return ((new Date).getTime()).toString(32);
}
var unique_key = getUniqueKey()