Skip to content

Instantly share code, notes, and snippets.

@termlen0
termlen0 / home_nas.sh
Created March 17, 2017 13:22
Backup laptop using rsync
I call it using a cronjob :
0 16 * * * /home/ajay/backup_scripts/home_nas.sh >> /home/ajay/temp/cronlog.log 2>&1
====
#!/bin/sh
ping -c5 -q 192.168.1.122
if [ $? -eq 0 ]
then /home/ajay/backup_scripts/backup.sh
exit 0
@termlen0
termlen0 / ec.desktop
Last active September 10, 2019 20:23 — forked from alexmurray/ec.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=Emacs
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=/home/termlen0/bin/emacs
Icon=emacs24
StartupWMClass=Emacs
@termlen0
termlen0 / es
Created April 17, 2017 15:40 — forked from alexmurray/es
Shutdown Emacs Server
#!/bin/bash
# Shamelessly taken from http://mjwall.com/blog/2013/10/04/how-i-use-emacs/
# simple script to shutdown the running Emacs daemon
# emacsclient options for reference
# -a Alternate editor, runs bin/false in this case
# -e eval the script
@termlen0
termlen0 / et
Created April 17, 2017 15:40 — forked from alexmurray/et
Start Emacs Client in Terminal (and launch Emacs server if not already running)
#!/bin/bash
# Shamelessly taken from http://mjwall.com/blog/2013/10/04/how-i-use-emacs/
# Makes sure emacs daemon is running and opens the file in Emacs in
# the terminal.
# If you want to execute elisp, use -e whatever, like so
# et -e "(message \"Word up\")"
@termlen0
termlen0 / ec
Created April 17, 2017 15:40 — forked from alexmurray/ec
Start Emacs Client in GUI (and launch Emacs server if not already running)
#!/bin/bash
# Shamelessly taken from http://mjwall.com/blog/2013/10/04/how-i-use-emacs/
# This script starts emacs daemon if it is not running, opens whatever file
# you pass in and changes the focus to emacs. Without any arguments, it just
# opens the current buffer or *scratch* if nothing else is open. The following
# example will open ~/.bashrc
# ec ~/.bashrc
@termlen0
termlen0 / emacs_notification_elisp.txt
Last active May 18, 2017 14:28
emacs notification methods - shell and alert
;; Method 1 - Using libnotify's notify-send from the shell
(defun test (title message)
(interactive)
(shell-command (format "notify-send \"%s\" \"%s\"" title message)))
(test "Test" "Something")
;; Method 2 - Using the emacs alert.el package, cleaner
(require 'alert)
(setq alert-default-style 'libnotify)
(alert "hello")
@termlen0
termlen0 / Vagrantfile
Created June 27, 2017 12:16
Vagrantfile to spin up 2 NXOSv switches
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.define "n9kv1" do |n9kv1|
n9kv1.vm.box = "nxos7"
n9kv1.ssh.insert_key = false
n9kv1.vm.boot_timeout = 180
@termlen0
termlen0 / nxos_config.txt
Created June 27, 2017 12:41
nxos iso file contents
root@NCC-1701:/mnt/tempdisk# cat nxos_config.txt
!Command: show running-config
!Time: Tue Jan 5 17:46:51 2016
version 7.0(3)I3(1)
vdc switch id 1
limit-resource vlan minimum 16 maximum 4094
limit-resource vrf minimum 2 maximum 4096
limit-resource port-channel minimum 0 maximum 511
TASK [connectivity_test : Wait 400 seconds (using wait_for_connection)] ***********************************************************
task path: /working/linklight/provisioner/roles/connectivity_test/tasks/main.yml:1
wait_for_connection: attempting ping module test
<52.23.216.23> ESTABLISH SSH CONNECTION FOR USER: ec2-user
<52.23.216.23> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o Port=22 -o 'IdentityFile="/working/linklight/provisioner/ajay-linklight/ajay-linklight-private.pem"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=ec2-user -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/9c11b3eb1e 52.23.216.23 '/bin/sh -c '"'"'echo ~ec2-user && sleep 0'"'"''
wait_for_connection: attempting ping module test
<35.173.255.200> ESTABLISH SSH CONNECTION FOR USER: ec2-user
<35.173.255.200> SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictH
@termlen0
termlen0 / ansible-role-test.sh
Last active September 5, 2018 00:12 — forked from geerlingguy/ansible-role-test.sh
Ansible Role Test Shim Script
#!/bin/bash
#
# Ansible role test shim.
#
# Usage: [OPTIONS] ./tests/test.sh
# - distro: a supported Docker distro version (default = "centos7")
# - playbook: a playbook in the tests directory (default = "test.yml")
# - role_dir: the directory where the role exists (default = $PWD)
# - cleanup: whether to remove the Docker container (default = true)
# - container_id: the --name to set for the container (default = timestamp)