Skip to content

Instantly share code, notes, and snippets.

@albal
albal / matrix.ino
Created July 13, 2014 13:01
Tisplay
/*
Al West, 2014, UK.
compiles to 6,240 bytes
Demonstrates the use a 20x4 LCD display as Matrix Orbital Device in LCD Smartie.
This should work all LCD displays that are compatible with the Hitachi HD44780 driver.
This sketch takes data from LCD Smartie emulating a Matrix Orbital and shows desired data.
@albal
albal / jenkins.yaml
Created February 8, 2018 11:55
Jenkins deployment from WAR
---
- hosts: hudson
vars:
webapps: "/var/lib/tomcat/webapps"
app_name: "ROOT"
app: "{{ webapps }}/{{ app_name }}"
war: "{{ app }}.war"
web: "{{ app }}/WEB-INF/web.xml"
key: "/root/hudson.pfx"
@albal
albal / random_date.py
Created May 23, 2018 09:34
Python random past date
#!/usr/bin/env python
import random
import time
import datetime
def strTimeProp(format, prop):
stime = time.mktime(time.strptime((datetime.datetime.now()+datetime.timedelta(-3650)).strftime(format), format))
etime = time.mktime(time.strptime(datetime.datetime.now().strftime(format), format))
ptime = stime + prop * (etime - stime)
return time.strftime(format, time.localtime(ptime))
apt-get install build-essential libssl-dev
wget "https://downloads.sourceforge.net/project/ibmtpm20tss/ibmtss1119.tar.gz?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fibmtpm20tss%2Ffiles%2Flatest%2Fdownload&ts=1527166281"
mv ibmtss1119.tar.gz\?r\=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fibmtpm20tss%2Ffiles%2Flatest%2Fdownload\&ts\=1527166281 ibmtss1119.tar.gz
mkdir ibm-tss
cd ibm-tss
cp ../ibmtss1119.tar.gz .
tar -zxvf ibmtss1119.tar.gz
cd utils
make
find . -newermt `date +"%Y-%m-%d"` -print0 | xargs -0 -I {} mv {} /usr/local/sbin
#!/usr/bin/env python
import datetime
import holidays
import calendar
workingdays_year = 0
uk_holidays=holidays.UK()
this_year=datetime.datetime.now().year
for month in range (1, 13):
weekdays = []
@albal
albal / apt-check
Created July 16, 2018 10:09
Ubuntu compatible update scripts for Centos
#!/bin/bash
# /usr/lib/update-notifier/apt-check
val=$(yum check-update --quiet | grep '^[a-Z0-9]' | wc -l)
echo "${val};${val}"
@albal
albal / evac_maint.ps1
Created November 23, 2018 14:36
VMware PowerCLI PowerShell script to shutdown VMs that would be left running on an ESX host entering maintenance mode
# Connect to vCenter
Connect-VIServer -Server 192.168.0.10 -user administrator@vsphere.local -password <password>
# Get the HostId of the VM Host entering maintenance mode - assuming only one Host in a Data Center at a time
$hostid = Get-Task Running | where {$_.name -eq "EnterMaintenanceMode_Task"} | select ObjectId
# If there is a result then shutdown all the VMs that match the name given
if (-not ([string]::IsNullOrEmpty($hostid)))
{
# Get the VM Host name by the ObjectId
$esxhost = Get-VMHost | where {$_.Id -eq $hostid.ObjectId}
# Shutdown the VM given by the wildcard - in this case any machine begninning with Gluster running on that host
@albal
albal / trx-to-junit.xslt
Created June 18, 2019 11:28 — forked from cdroulers/trx-to-junit.xslt
Transform dotnet test output (TRX) to jUnit format for CI purposes.
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a ="http://microsoft.com/schemas/VisualStudio/TeamTest/2006" xmlns:b ="http://microsoft.com/schemas/VisualStudio/TeamTest/2010" >
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<testsuites>
<xsl:variable name="buildName" select="//a:TestRun/@name"/>
<xsl:variable name="numberOfTests" select="count(//a:UnitTestResult/@testId) + count(//b:UnitTestResult/@testId)"/>
<xsl:variable name="numberOfFailures" select="count(//a:UnitTestResult/@outcome[.='Failed']) + count(//b:UnitTestResult/@outcome[.='Failed'])" />
<xsl:variable name="numberOfErrors" select="count(//a:UnitTestResult[not(@outcome)]) + count(//b:UnitTestResult[not(@outcome)])" />
<xsl:variable name="numberSkipped" select="count(//a:UnitTestResult/@outcome[.!='Passed' and .!='Failed']) + count(//b:UnitTestResult/@outcome[.!='Passed' and .!='Failed'])" />
@albal
albal / scramble.py
Created April 5, 2020 01:09
Scramble Name
import sys, time, random, string
name = "Daniel Michael Blake Day-Lewis"
length = len(name)
output = ""
def randomString(stringLength=10):
"""Generate a random string of fixed length """
letters = string.ascii_lowercase
@albal
albal / third.py
Created January 19, 2021 18:25
Make a third from the numbers 1 - 9
# You have the numbers 1 - 9, arrange them to make a third
from itertools import permutations
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]
top = permutations(nums, 4)
bottom = permutations(nums, 5)
top_vals = list(top)
bottom_vals = list(bottom)
count = 0