Posts categorized under: tech

Giving Circle CI a Shot

Migrating from Jenkins to CircleCI

The reason being that hosting and maintaining a Jenkings server and its underlying Kubernetes infrastructure was getting a bit time consuming for some of the guys at work. CircleCI seemed a good alternative to employing extra DevOps staff to look after the ever increasing demands …

Slack Cleaner

If you find you're running out of space on Slack, it may be that you have too many images floating in storage. However, deleting them via the Slack interface is tedious to say the least.

Enter stage left: the Slack API. Here's a script I wrote to list and then …

Grrr Talend

The company I work for really likes Talend at the moment. However, they often don't consider that, as great as Talend is, it seemingly cannot do things like take in command line parameters. For instance, like a date that you'd like to regenerate a data extract job for.

The only …

Managing The Joys of Jira

Managing the joys of Jira

We all know and love Jira, especially when one needs to log time and perform other soul-sucking activities.

I wrote the following script to help make working with Jira a little bit more palatable.

Functions include deleting all the annoying email-footer images that get attached …

20 Lines of Python

Querying a Database and POSTing data in 20 lines

I love Python and its many libraries. The HTTP library by the name of requests is particularly awesome.

Note: I have not used any authentication, basic or otherwise, but it's easy enough to add.

StringIO is used because the cvs library …

MySQL Backup Script

#!/bin/bash

user='root'
pass='r00t'
date=$(date +%Y.%m.%d)
backuproot='/var/backups/mysql'

# echo and exit
function die {
    echo "$1"
    exit 1
}

# dump per database
function per_db {
    for db in $(mysql -u ${user} -p${pass} -Bse "show databases"); do
        [ ${db} = "information_schema" ] && continue
        [ ${db} = "performance_schema" ] && continue
        echo ${db}
        mysqldump …

Discovering the Seagate Central

NMAP Scan

ryant@spitfire:~$ nmap 192.168.1.11

Starting Nmap 6.00 ( http://nmap.org ) at 2013-06-29 13:17 SAST
Nmap scan report for 192.168.1.11
Host is up (0.0098s latency).
Not shown: 990 closed ports
PORT     STATE SERVICE
21/tcp   open  ftp
22/tcp   open …

Expect the Unexpected

Problem

Need to automate an rsync to a fileserver and, unfortunately, required to authenticate using a password.

Solution

Use expect...

#!/usr/bin/expect

set timeout 20
set password [lindex $argv 0]

spawn rsync -av --no-p --no-g  /media/ryant/My\ Book/Photo/ user@10.10.10.12:/Data/Public/Photos/

expect …

Persistence With SQLite

The Problem-ette

I needed to keep track of up until where in a database table I had already queried. Later queries needed to draw data from that point onwards. For example if I've done the query select id, name, surname from table where id > 255623 and it yielded results with …

Do They Fit?

Do you want to know if the MP3s in that folder will fit on a CD?

No problem.

#!/usr/bin/env python

import audioread
import sys

try:
    files = sys.argv[1:]
except:
    print('Usage: %s <files/glob>' % (sys.argv[0],))
    sys.exit()

total_length = 0.0
for file in files:
    f …

Commandline Completion for Fabric

To get a list of functions in a Fabric file you use fab --list. I use Fabric frequently so I thought I'd save myself some time by using bash completion to render fab --list obsolete.

Being a learn-from-example type of person I immediately consulted Google for some precedence. After a …

MySQL Over an SSH Tunnel

The Problem-ette

I need to access a number of MySQL servers which are only accessible via ssh jump boxes, ie. I have to ssh to Box A in order to connect to Box B via SSH or the MySQL client.

This can get a bit tedious.

The Solution

Being able …

Keeping IT Simple With Web.py

The web framework shootout

There are many Python based web frameworks out there waiting to be discovered, tested, set aside, and even used for something useful. Some argue that there are too many and that what Python needs is a Rails-style killer app. One app to rule them all… Like …

SQL Converter

The Problem

I had a text file containg MS SQL Server database table definitions and I needed to make it compatible with MySQL. Here’s an example:

GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Blecchs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo …

Twisted Exim

Use the source, Luke

The great thing about open source is that you can learn from those who have published code on the 'net. At the very least you can shamelessly plagiarise it and bend it until it looks like something you could use ;-)

Another great thing about OSS is …