Skip to content

Instantly share code, notes, and snippets.

@wirewc
wirewc / load_aws_profile.sh
Last active April 22, 2023 02:51
AWS Profile Switcher with Google Auth Token
#!/usr/bin/bash
export ENVIRONMENT_NAME="AWS"
export ENV="dev" # Example of an additional variable
export AWS_MFA_ARN=arn:aws:iam::12345678456:mfa/MySecurityToken # TODO: change value
export AWS_ACCESS_KEY_ID=My_Secret_Access_ID
export AWS_SECRET_ACCESS_KEY=My_Secret_Access_Key
@wirewc
wirewc / gist:4d4dc4726201487a80ba2e6ccb876548
Created February 2, 2018 05:58
Blockstack Verification
Verifying my Blockstack ID is secured with the address 1Dm17dxjmg4YZZbgN4E3YALgaHUf5GyZPA https://explorer.blockstack.org/address/1Dm17dxjmg4YZZbgN4E3YALgaHUf5GyZPA
@wirewc
wirewc / x2go-cron-cleanup.sh
Last active July 12, 2018 23:58
Closes idle X2Go sessions that are open over 1 week.
#!/bin/bash
LIMIT_DAYS=7
TIME_ZONE=$(date +%Z)
DEBUG=false
for session in $(x2golistsessions_root); do
#Get state
state=$(echo $session|awk -F \| '{print $5}')
@wirewc
wirewc / InventoryPull.py
Created April 21, 2017 16:49
Pulls inventory from Satellite/The Foreman and takes systems that have reported in the last day to create an Ansiblie Inventory.
"""Written for Python 3.5, works on 2.7.3 +
Pip install the following moduels:
psycopg2==2.7.1
PyYAML==3.12
Copyright (C) 2017 William Christensen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@wirewc
wirewc / chroot.sh
Created April 12, 2017 18:34
Builds a chroot from scratch from other CentOS/RHEL 7 boxes.
#!/bin/bash
# Name of Container as the argument to the script.
CNAME=$1
mkdir -p /srv/nspawns/$CNAME/var/lib/rpm; rpm --rebuilddb --root=/srv/nspawns/$CNAME
mkdir /srv/nspawns/isos; cd /srv/nspawns/isos;
wget http://mirror.centos.org/centos-7/7/os/x86_64/Packages/centos-release-7-3.1611.el7.centos.x86_64.rpm
rpm -i --root=/srv/nspawns/$CNAME --nodeps /srv/nspawns/isos/centos-release-7-3.1611.el7.centos.x86_64.rpm
yum --installroot=/srv/nspawns/$CNAME install -y rpm-build yum net-tools openssh-server vim systemd-networkd iproute hostname screen iputils dhclient passwd
echo $CNAME > /srv/nspawns/$CNAME/etc/hostname
@wirewc
wirewc / player.py
Last active September 26, 2016 15:28
Video Looper for a Raspberry Pi
#!/usr/bin/python3
"""
# Summary: Created by request for a project involving looping through videos on a Raspberry Pi.
#
# Inside Joke: Created for the New Biebs on the Block
#
#
#Copyright (c) 2016 Will Christensen<wirewc@gmail.com>
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
@wirewc
wirewc / General Simple Makefile with debug
Last active October 3, 2016 17:35
General simple makefile I share with students and friends learning C or C++
CC = g++
CFLAGS = -std=c++14 -Wall -fPIC -g
LDFLAGS = -std=c++14 -Wall -fPIC -g
TARGET = stuff
all: $(TARGET)
$(TARGET): $(TARGET).o
$(CC) -o $@ $^ $(LDFLAGS)
@wirewc
wirewc / stringFunctionSet.c
Last active August 29, 2015 14:12
Example code to popular a char pointer in a function through a function argument pointer. This example is for anyone who has beat their against the wall. This example is used as a mock up for how one may try pull a buffer from a microcontroller that is built for a UART interrupt.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void copy_string(char *target, char *source)
{
while(*source)
{
*target = *source;
source++; target++;
@wirewc
wirewc / news.py
Created September 3, 2014 19:05
News for MakePi
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
"""This reads the news for google news."""
import feedparser,requests,json,urllib,urllib2
tech = """https://news.google.com/news/section?pz=1&cf=all&ned=us&hl=en&topic=tc&output=rss"""
archNewsUrl = """https://www.archlinux.org/feeds/news/"""
hadUrl = """http://feeds2.feedburner.com/hackaday/LgoM"""
mlvUrl= """http://makelehighvalley.com/blog/feed/"""
h76Url = """http://feeds.feedburner.com/Hive76"""
crackedUrl = """http://feeds.feedburner.com/CrackedRSS"""
@wirewc
wirewc / PhennyNews.py
Last active August 29, 2015 14:06
News module for the IRC bot makepi for #makelv and #archassault.
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
"""This reads the news for google news."""
import feedparser,requests,json,urllib,urllib2
tech = """https://news.google.com/news/section?pz=1&cf=all&ned=us&hl=en&topic=tc&output=rss"""
archNewsUrl = """https://www.archlinux.org/feeds/news/"""
hadUrl = """http://feeds2.feedburner.com/hackaday/LgoM"""
mlvUrl= """http://makelehighvalley.com/blog/feed/"""
h76Url = """http://feeds.feedburner.com/Hive76"""
crackedUrl = """http://feeds.feedburner.com/CrackedRSS"""