Skip to content

Instantly share code, notes, and snippets.

View guyc's full-sized avatar

Guy Carpenter guyc

  • Clearwater Software
  • Australia
View GitHub Profile
@guyc
guyc / hipchat-notify.rb
Created July 11, 2014 01:41
zabbix notifier for hipchat
#!/usr/local/rvm/rubies/ruby-1.9.3-p547/bin/ruby
# Guy Carpenter - 11 Jul 2014
require 'rubygems'
require 'hipchat'
# API: https://github.com/hipchat/hipchat-rb
# https://www.hipchat.com/docs/api/method/rooms/message
to = ARGV[0]
subject = ARGV[1] # <Host>:(PROBLEM|OK):(Warning|Error|):<Name>
@guyc
guyc / custom_query.py
Last active August 29, 2015 14:04
Tools for writing efficient zabbix custom queries. Includes data collection for mysqladmin extended-status, mysql show slave status and port usage collected with ss
#!/usr/bin/python
#
# Command-line:
# Dump everything
# ./portstat.py
#
# Dump specific value
# ./portstat.py state-time-wait
#
# UserParameter=oth.port[*],/etc/zabbix/scripts/portstat.py '$1'
@guyc
guyc / Forgiveness
Last active August 29, 2015 14:12
This is a Groovy script for Jenkins that will change the first failure to a success status, subsequent failures will be reported as failures. We use this to shut up spurious failure notifications for intermittent failures while we get some false alarms from our Sahi monitoring system ironed out.
Boolean failed = manager.getResult() != "SUCCESS";
def file = new File(manager.build.getWorkspace().getRemote() + '/FailedBuildsCount.txt');
def count = 0;
if (failed) {
if (!file.exists()) {
file.createNewFile();
} else {
FileReader reader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(reader);
@guyc
guyc / prepare-commit-msg.rb
Created April 5, 2011 03:09
git hook to add the first subdirectory name in the repo to the commit message.
#!/usr/bin/ruby
#
# Save this file as GITDIR/.git/hooks/prepare-commit-msg
# where GITDIR is the top directory of your git repository.
# then chmod +x prepare-commit-msg
#
# This hook is invoked by 'git-commit' right after preparing the default log
# message, and before the editor is started.
#
# It takes one to three parameters. The first is the name of the file that the commit
@guyc
guyc / 2.6.28.diff
Created February 16, 2012 06:41
Shows the differences in the boot log between the stock Chumby disk image and the 2.6.28 OpenEmbedded build from https://github.com/clearwater/chumby-linux
--- bootlog.stock.tmp 2012-02-17 15:02:18.000000000 +1000
+++ bootlog.2.6.28.tmp 2012-02-17 15:02:18.000000000 +1000
@@ -5,37 +5,37 @@
Skipping 3968 chunks
Jumping to address 0x40808000:
0x00000000 0f 00 a0 e1 08 00 40 e2 02 0a 40 e2 08 10 9f e5 |......@...@.....|
-0x00000010 00 00 81 e5 02 00 00 eb 25 05 00 eb 20 20 00 00 |........%... ..|
+0x00000010 00 00 81 e5 02 00 00 eb d8 04 00 eb 20 80 80 40 |............ ..@|
0x00000020 11 b1 11 c1 14 00 9f e5 14 10 9f e5 00 20 a0 e3 |............. ..|
0x00000030 04 20 80 e4 01 00 50 e1 fc ff ff 3a 0e f0 a0 e1 |. ....P....:....|
/*
This software uses a BSD license.
Copyright (c) 2010, Sean Cross / chumby industries & Limor Fried / adafruit industries (we are both industrious people, eh?)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
@guyc
guyc / Command.cpp
Created May 3, 2012 03:33
The file that is currently on an Arduino Uno with a serial number of 64932343738351217080
/*
Copyright (c) 2011 Guy Carpenter
*/
#include <Arduino.h>
#include "Command.h"
#define CMDBUF_LEN 40
@guyc
guyc / ConstantSpeedTest.ino
Created May 4, 2012 00:09
The file that is currently on an Arduino Uno with a serial number of 6493832333135140D160
#define PIN_VCC 3
#define PIN_GND 4
#define PIN_SENSE A0
#define FORWARD 1
#define REVERSE -1
#define SAFE_DELAY 1000
#define COUNT_DELAY 1000
@guyc
guyc / i2ctest.c
Created September 17, 2012 05:08
Testing driving a SwitecX25 stepper over i2c using an MCP23008 I/O chip
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@guyc
guyc / font_test2.py
Created November 18, 2012 23:56
code for testing font layout using py-gaugette.ssd1306
import gaugette.ssd1306
from gaugette.fonts import arial_16
from gaugette.fonts import arial_mono_15
RESET_PIN = 15
DC_PIN = 16
buffer_width = 128