Skip to content

Instantly share code, notes, and snippets.

View jbarber's full-sized avatar

Jonathan Barber jbarber

View GitHub Profile
@jbarber
jbarber / xml-parse.go
Created July 9, 2014 14:21
Example of parsing XML in Go, including extracting attributes
package main
import (
"encoding/xml"
"log"
"strings"
)
type document struct {
Title string `xml:"title"`
@jbarber
jbarber / rhel5.ks
Created August 25, 2011 16:34
RHEL5 kickstart example
# Example Kickstart config file for RHEL5, change $VARIABLES to suitable values
# for your site
# Usage from linux kernel boot prompt:
# linux ks=http://$SERVER_ADDR/ks/rhel5-example.ks ip=$IPADDR netmask=$NETMASK gateway=$GATEWAY [nokill] [keymap=pt-latin1] [noipv6] [debug]
#
# More boot options at http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/ch-bootopts-x86.html
# Options for this section can be found at http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Installation_Guide/s1-kickstart2-options.html
install
@jbarber
jbarber / LdapAuth.java
Created June 11, 2012 12:20
LDAP example for searching and simple binding (authentication)
/*
* First create the keystore (to allow SSL protection) by importing the LDAP
* certificate (cert.pem) with:
* keytool -import -keystore keystore -storepass changeit -noprompt -file cert.pem
*
* You can get the certificate with OpenSSL:
* openssl s_client -connect ldap.server.com:636 </dev/null 2>/dev/null | sed -n '/^-----BEGIN/,/^-----END/ { p }' > cert.pem
*
* Then compile this class with:
* javac LdapAuth.java
@jbarber
jbarber / get_repos.rb
Last active December 2, 2020 16:30
Github GraphQL query for repos, their topics, and Gemfile
require 'httparty'
require 'json'
require 'byebug'
def get_data
query = File.open('repos.graphql', 'r').read
token = 'https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/'
cursor = nil
repos = []
org = 'evil_mega_corp'
def log_object(job_id, step_id, bucket, key)
puts ['found', job_id, step_id, bucket, key].join(',')
end
def log_missing(job_id, object_id, msg)
puts ['missing', job_id, object_id, msg].join(',')
end
# Finding the offending RfTests
rf_test_ids = RfTest.where(client_id: 5627)
@jbarber
jbarber / pagerduty_incidents.rb
Created September 24, 2019 15:41
Extract all the PagerDuty incidents for analysis
require 'httparty'
require 'uri'
require 'csv'
def get_incidents
limit = 100
url = "https://api.pagerduty.com/incidents?statuses%5B%5D=resolved&time_zone=UTC&limit=#{limit}&offset="
incidents = []
offset = 0
@jbarber
jbarber / calendar_events.rb
Last active September 24, 2019 15:39
List events in google calendar
# gem install google-api-client
require "google/apis/calendar_v3"
require "googleauth"
require "googleauth/stores/file_token_store"
require "date"
require "fileutils"
OOB_URI = "urn:ietf:wg:oauth:2.0:oob".freeze
APPLICATION_NAME = "Google Calendar API Ruby Quickstart".freeze
@jbarber
jbarber / chrome-reload
Last active June 30, 2018 17:38
Reload Chrome tabs from the command line with Perl
#!/usr/bin/env perl
=head1 NAME
chrome-reload
=head1 SYNOPSIS
chrome-reload 1
@jbarber
jbarber / 10-install_binaries.sh
Created July 20, 2011 10:18
Quick Oracle 11g install on RHEL5
#!/bin/bash
set -e
. CONFIG
# Satisfy the prerequisites for Oracle 11g and install the binaries
for i in oinstall dba oper asmadmin asmdba asmoper; do groupadd $i; done
useradd -g oinstall -G dba,oper,asmdba oracle
useradd -g oinstall -G asmadmin,asmdba,asmoper grid
@jbarber
jbarber / example.sh
Last active March 27, 2018 20:51
Prototypical Ruby event machine based webserver for serving context over unix domain sockets
$ echo '{"foo": "bar"}' | curl --unix-socket /tmp/foo.bar http://www.google.com/echo -d @-
{"message":"{\"foo\": \"bar\"}"}
$ curl --unix-socket /tmp/foo.bar http://www.google.com/popper
{"message":"🎉"}