Skip to content

Instantly share code, notes, and snippets.

crontab add oneliner

(crontab -l; echo "0 */4 * * * ls")| crontab -

external IP to environment variable

export EXTERNAL_IP=$(dig @resolver1.opendns.com ANY myip.opendns.com +short)

Adding a secret to environment variable without echoing to console

@aidmax
aidmax / README-setup-tunnel-as-systemd-service.md
Created January 19, 2019 05:52 — forked from drmalex07/README-setup-tunnel-as-systemd-service.md
Setup a secure (SSH) tunnel as a systemd service. #systemd #ssh #ssh-tunnel #ssh-forward

README

Create a template service file at /etc/systemd/system/secure-tunnel@.service. The template parameter will correspond to the name of target host:

[Unit]
Description=Setup a secure tunnel to %I
After=network.target

Bash function to execute a sequence of commands with time tracking and error handling


#!/bin/bash

do_cmd()
{
    SECONDS=0

 echo
@aidmax
aidmax / mongodb_perf.md
Last active January 17, 2019 11:32 — forked from rantav/README.md
Find slow queries in mongo DB

A few show tricks to find slow queries in mongodb

Enable profiling

First, you have to enable profiling

> db.setProfilingLevel(1)

Now let it run for a while. It collects the slow queries ( > 100ms) into a capped collections, so queries go in and if it's full, old queries go out, so don't be surprised that it's a moving target...

# This tells kubecfg to read its config from the local directory
export KUBECONFIG=./kubeconfig
# Looking at the cluster
kubectl get nodes
kubectl get pods --namespace=kube-system
# Running a single pod
kubectl run --generator=run-pod/v1 --image=gcr.io/kuar-demo/kuard-amd64:1 kuard
kubectl get pods
pip freeze > requirements.txt
and distribute that. T
his will allow others using your project to reinstall all the same requirements into their virtualenv with:
pip install -r requirements.txt
brew install watch
output google_compute_image extension:tf
rpm user:geerlingguy
@aidmax
aidmax / tmux-cheatsheet.markdown
Created January 3, 2019 14:27 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@aidmax
aidmax / Jenkinsfile.groovy
Created December 15, 2018 07:35 — forked from Faheetah/Jenkinsfile.groovy
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"