Skip to content

Instantly share code, notes, and snippets.

@albertbori
albertbori / Installation.md
Last active May 4, 2024 18:21
Automatically disable Wifi when an Ethernet connection (cable) is plugged in on a Mac

Overview

This is a bash script that will automatically turn your wifi off if you connect your computer to an ethernet connection and turn wifi back on when you unplug your ethernet cable/adapter. If you decide to turn wifi on for whatever reason, it will remember that choice. This was improvised from this mac hint to work with Yosemite, and without hard-coding the adapter names. It's supposed to support growl, but I didn't check that part. I did, however, add OSX notification center support. Feel free to fork and fix any issues you encounter.

Most the credit for these changes go to Dave Holland.

Requirements

  • Mac OSX 10+
  • Administrator privileges
@P7h
P7h / tmux__CentOS__build_from_source.sh
Last active May 2, 2024 01:27
tmux 2.0 and tmux 2.3 installation steps for Ubuntu. Or build from tmux source v2.5 for Ubuntu and CentOS.
# Steps to build and install tmux from source.
# Takes < 25 seconds on EC2 env [even on a low-end config instance].
VERSION=2.7
sudo yum -y remove tmux
sudo yum -y install wget tar libevent-devel ncurses-devel
wget https://github.com/tmux/tmux/releases/download/${VERSION}/tmux-${VERSION}.tar.gz
tar xzf tmux-${VERSION}.tar.gz
rm -f tmux-${VERSION}.tar.gz
cd tmux-${VERSION}
@devynspencer
devynspencer / freeipa.py
Last active April 23, 2024 20:53
Use FreeIPA hostgroups as a dynamic inventory source for Ansible. Badass.
#!/usr/bin/env python
import argparse
import json
from ipalib import api
def initialize():
'''
This function initializes the FreeIPA/IPA API. This function requires
@0x3333
0x3333 / output.md
Last active April 9, 2024 13:38
Show Memory and CPU usage of kvm vms
RAM
---
vm-1                      = 1,024 MiB
vm-2                      = 2,048 MiB

Total: 3,072 MiB

CPU(s)
------
@lpla
lpla / MQTT-influxDB-telegraf-grafana-in-armv6-raspberry.md
Last active April 6, 2024 10:28
Install MQTT + influxDB + telegraf + grafana in Raspberry Pi 1 or Zero (armv6)

I tried to install this set of technologies for an small home project using BME280 in a Raspberry Pi Zero, but all guides I tried to follow are based on newer Raspberry Pi versions (armv7) (like this guide or this one), so the docker instructions don't work for some of these packages.

TL;DR: don't use any docker image, use only apt commands and repos from each project official documentation

Mosquitto (MQTT)

As official documentation details, simply use the already available package from Raspbian/Raspberry Pi OS archive repository:

@terrancesnyder
terrancesnyder / setenv.sh
Created May 23, 2011 00:07
./setenv.sh - example setenv.sh with defaults set for minimal time spent in garbage collection
#! /bin/sh
# ==================================================================
# ______ __ _____
# /_ __/___ ____ ___ _________ _/ /_ /__ /
# / / / __ \/ __ `__ \/ ___/ __ `/ __/ / /
# / / / /_/ / / / / / / /__/ /_/ / /_ / /
#/_/ \____/_/ /_/ /_/\___/\__,_/\__/ /_/
# Multi-instance Apache Tomcat installation with a focus
# on best-practices as defined by Apache, SpringSource, and MuleSoft
@ksafranski
ksafranski / expecting.md
Last active November 11, 2023 23:00
Basic principles of using tcl-expect scripts

Intro

TCL-Expect scripts are an amazingly easy way to script out laborious tasks in the shell when you need to be interactive with the console. Think of them as a "macro" or way to programmaticly step through a process you would run by hand. They are similar to shell scripts but utilize the .tcl extension and a different #! call.

Setup Your Script

The first step, similar to writing a bash script, is to tell the script what it's executing under. For expect we use the following:

#!/usr/bin/expect
@Aethylred
Aethylred / gist:0ea0d2899eca1da790aa078f9f2a885a
Last active October 31, 2023 20:52
freeipa-api-ansible-inventory
#!/usr/bin/env python
# This script uses the FreeIPA API to create an Ansible dynamic directory
# This is a shell script version of freeipa-api-inv.py
#
# DEPENDENCIES: before this script will work with AWX or Tower
# the python_freeipa module has to be installed
#
# Add this to your Docker image
# RUN pip install python_freeipa
#
@bzerangue
bzerangue / macs-on-active-directory.md
Last active October 12, 2023 21:07
Binding and Unbinding to Active Directory from Mac OS via Command Line

Binding and Unbinding to Active Directory from Mac OS via Command Line

  • Open the Terminal Application
  • Type in sudo -i and type in your Mac Administrator account password. sudo gives you root level or administrator level privileges.

To View current Active Directory Settings

dsconfigad -show

To Unbind a Computer from an Active Directory Domain

#!/usr/bin/python
# As written, this requires the following:
# - OS X 10.6+ (may not work in 10.10, haven't tested)
# - python 2.6 or 2.7 (for collections.namedtuple usage, should be fine as default python in 10.6 is 2.6)
# - pyObjC (as such, recommended to be used with native OS X python install)
# Only tested and confirmed to work against 10.9.5
# Run with root