Skip to content

Instantly share code, notes, and snippets.

View athaller's full-sized avatar
💭
Making Magic

athaller

💭
Making Magic
  • $date :: PHP :: Systems :: Dev Ops
  • East :: Web
View GitHub Profile
@athaller
athaller / gist:3a03e14eacbac028ef36
Created January 22, 2016 17:35 — forked from mig5/gist:a89af7d113f403521cd7
Bring Vagrant VM up if it's off and you tried to vagrant ssh
vagrant() {
if [[ $@ == "ssh" ]]; then
command vagrant ssh || command vagrant up && command vagrant ssh
else
command vagrant $@
fi
}
@athaller
athaller / vcloud-vm-lookup.sh
Created January 22, 2016 17:36 — forked from mig5/vcloud-vm-lookup.sh
vcloud-vm-lookup
#!/bin/bash
usage() {
cat << EOF
usage: $0 ARGUMENTS
Simple wrapper script to query the vCloud API and return a
YAML object of a specific virtual machine.
Written by mig5 July 2014
<?php
$aliases['server_clusterwebmig5net'] = array (
'context_type' => 'server',
'server' => '@server_master',
'remote_host' => 'cluster-web.mig5.net',
'aegir_root' => '/var/aegir',
'script_user' => 'aegir',
'ip_addresses' =>
array (
0 => '106.187.40.34',
@athaller
athaller / build
Created January 22, 2016 17:37
aegir platform build/import script
#!/bin/sh
############################################################
# Aegir build script #
# Builds a platform from a supplied Drush make stub file #
# and saves/imports it into an Aegir system #
# #
# Written by Miguel Jacq (mig5) of Green Bee Digital #
# February 2011 #
############################################################
#!/bin/bash
sudo apt-get update
sudo apt-get -y install python-setuptools python-dev libffi-dev libssl-dev git sshpass
sudo easy_install pip
sudo -H pip uninstall -y virtualenv
sudo -H pip uninstall -y virtualenvwrapper
sudo -H pip install virtualenv
sudo -H pip install virtualenvwrapper --ignore-installed six
sudo -H pip install httplib2
@athaller
athaller / plwatch.sh
Created March 17, 2016 14:45 — forked from lrq3000/plwatch.sh
A simple bash script to watch packets loss using ping on Unix/Linux
#!/bin/bash
# Packets Loss Watch
# Simple SHELL script for Linux and UNIX system monitoring with
# ping command
#
# Copyright (c) 2006 nixCraft project <http://www.cyberciti.biz/fb/>
# Copyleft 2013 Stephen Larroque
# This script is licensed under GNU GPL version 2.0 or above
#
# This script was inspired by a nixCraft script http://www.cyberciti.biz/tips/simple-linux-and-unix-system-monitoring-with-ping-command-and-scripts.html
@athaller
athaller / 0_reuse_code.js
Created March 18, 2016 18:16
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

Opening and closing an SSH tunnel in a shell script the smart way

I recently had the following problem:

  • From an unattended shell script (called by Jenkins), run a command-line tool that accesses the MySQL database on another host.
  • That tool doesn't know that the database is on another host, plus the MySQL port on that host is firewalled and not accessible from other machines.

We didn't want to open the MySQL port to the network, but it's possible to SSH from the Jenkins machine to the MySQL machine. So, basically you would do something like

ssh -L 3306:localhost:3306 remotehost

@athaller
athaller / auto-remove-sublime-license-popup
Created July 12, 2016 20:01 — forked from egel/auto-remove-sublime-license-popup
Auto-remove Sublime's license popup
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sublime_plugin
import subprocess
from time import sleep
import sys
cl = lambda line: subprocess.Popen(line, shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
log = lambda message: sys.stderr.write("Log: %s\n" % message)
@athaller
athaller / new_gist_file_0
Created July 15, 2016 13:19 — forked from zachharkey/new_gist_file_0
Use drush to save a list of all enabled non-core modules to a text file, then disable/re-enable all modules on that list
#
drush pml --no-core --type=module --status=enabled --pipe > modules.txt
cat modules.txt | xargs drush -y dis
cat modules.txt | xargs drush -y en