Skip to content

Instantly share code, notes, and snippets.

@bunchc
bunchc / logger.sh
Created February 28, 2017 16:40
Bash Color Logging
# EasyColors
if [ ${libout_color:-1} -eq 1 ]; then
DEF_COLOR="\x1b[0m"
BLUE="\x1b[34;01m"
CYAN="\x1b[36;01m"
GREEN="\x1b[32;01m"
RED="\x1b[31;01m"
GRAY="\x1b[37;01m"
YELLOW="\x1b[33;01m"
fi
@bunchc
bunchc / ubuntu-14.04.json
Created March 8, 2017 16:52
packer template for ubuntu
{
"variables": {
"vsphere_host": "vcenter65-1.vghetto.local",
"vsphere_user": "administrator@vghetto.local",
"vsphere_pass": "VMware1!",
"vsphere_datacenter": "Datacenter",
"vsphere_cluster": "\"VSAN-Cluster\"",
"vsphere_datastore": "virtual_machines",
"vsphere_network": "\"VM Network\""
},
@bunchc
bunchc / solarized-slack.js
Created April 24, 2018 03:49
solarized-slack
function applycss(css){
var head = document.getElementsByTagName('head')[0];
var s = document.createElement('style');
s.setAttribute('type', 'text/css');
s.appendChild(document.createTextNode(css));
head.appendChild(s);
}
applycss(`
body { background: #002b36; color: #839496; }
a { color: #90939b; }
---
- name: Create a partition with drive letter D and size 1020 GiB
hosts: "{{host}}"
tasks:
- name: do the thing
win_partition:
drive_letter: D
partition_size: 1020 GiB
disk_number: 2
@bunchc
bunchc / hub_ctrl.py
Created February 11, 2019 21:49
There Are Door Lights - hub_ctrl mods
def send_command(listing, busnum, devnum, hub, port, value, verbose):
""" send_command(self, parameter_list)
Sends the power control command to the USB hub.
"""
if hub == None and busnum == None:
hub = 0 # Default hub = 0
cmd = COMMAND_SET_POWER
@bunchc
bunchc / door_sensor.py
Last active February 11, 2019 21:31
There Are Door Lights - Light Sensor
from gpiozero import LightSensor
import hub_ctrl
sensor = LightSensor(4)
print(sensor.light_detected)
while True:
# sensor.when_light = hub_ctrl.send_command(listing=True, busnum=1, devnum=2, hub=None, port=2, value=1, verbose=False)
sensor.wait_for_light()
hub_ctrl.send_command(listing=True, busnum=1, devnum=2, hub=None, port=2, value=1, verbose=False)
@bunchc
bunchc / hub_ctrl.py
Created February 11, 2019 21:28
There Are Four Lights - USB Control
#! /usr/bin/python
"""
hub_ctrl.py - a tool to control port power/led of USB hub
Copyright (C) 2006, 2011, 2016 Free Software Initiative of Japan
Author: NIIBE Yutaka <gniibe@fsij.org>
This file is a part of Gnuk, a GnuPG USB Token implementation.
@bunchc
bunchc / Dockerfile
Last active February 11, 2019 21:23
There Are Door Lights
FROM arm32v6/alpine:latest
RUN apk --no-cache add \
bash \
python3 \
python3-dev \
build-base \
vim \
git \
curl \
@bunchc
bunchc / customize.sh
Created January 17, 2018 20:25
Supporting files for packer-builder-arm-image
#!/bin/bash
set -x
# Localse, uncomment if user-data didn't fix these
export LANGUAGE=en_US.UTF-8; export LANG=en_US.UTF-8; export LC_ALL=en_US.UTF-8; locale-gen en_US.UTF-8
# Set locale to en_US.UTF-8
sudo cp /etc/locale.gen /etc/locale.gen.dist
sudo sed -i -e "/^[^#]/s/^/#/" -e "/en_US.UTF-8/s/^#//" /etc/locale.gen
@bunchc
bunchc / install_adfs.ps1
Created May 9, 2018 21:20
Install and configure adfs with powershell
$domainName = "{{ windows_domain_info['dns_domain_name'] }}"
$password = "{{ windows_domain_info['domain_admin_password'] }}"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$fqdn = [System.Net.Dns]::GetHostByName(($env:computerName)) | FL HostName | Out-String | %{ "{0}" -f $_.Split(':')[1].Trim() };
$filename = "C:\$fdqn.pfx"
$user = "{{ windows_domain_info['dns_domain_name'] }}\{{ windows_domain_info['domain_admin_user'] }}"
$credential = New-Object `
-TypeName System.Management.Automation.PSCredential `
-ArgumentList $user, $securePassword