Skip to content

Instantly share code, notes, and snippets.

View thomastaylor312's full-sized avatar

Taylor Thomas thomastaylor312

View GitHub Profile
@thomastaylor312
thomastaylor312 / calculateParity.c
Last active December 28, 2015 16:59
A small, slightly hacky C program to calculate the parity of data and then compare it using modified data. This will probably be used for some sort of homework assignment.
#include <stdio.h>
//Code for calculate parity from http://graphics.stanford.edu/~seander/bithacks.html#ParityNaive
unsigned int calculateParity(int data) {
unsigned int parity = 1; //Even parity to start
while (data) {
parity = !parity;
data = data & (data - 1);
}
return parity;
@thomastaylor312
thomastaylor312 / jjb.yml
Last active October 5, 2016 21:01
An example of a project with job parameters
- project:
name: cassandra
parameters:
- foo
jobs:
- "deployment-tests-{name}"
- job-template:
name: "deployment-tests-{name}"
description: "Tests the deployment of {name}"
Wed Nov 2 20:36:18 UTC 2016
@thomastaylor312
thomastaylor312 / example-secret.yml
Created November 3, 2016 22:04
Example secret file for Kubernetes
---
apiVersion: v1
kind: Secret
metadata:
name: password
namespace: my-cool-ns
data:
password: foobarbaz
@thomastaylor312
thomastaylor312 / jenkins-credentials.groovy
Last active November 3, 2016 22:29
How to set credentials for Jenkins in Kubernetes
import jenkins.model.*
import hudson.model.*
import hudson.security.SecurityRealm
import org.jenkinsci.plugins.GithubSecurityRealm
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.plugins.credentials.impl.*
import com.cloudbees.jenkins.plugins.sshcredentials.SSHUserPrivateKey
import com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey
@thomastaylor312
thomastaylor312 / example-config.yml
Last active November 3, 2016 23:10
An example ConfigMap
---
apiVersion: v1
kind: ConfigMap
metadata:
name: alert-rules
data:
foo-file: |
foo: bar
whiz: bang
special.conf: |
@thomastaylor312
thomastaylor312 / example-deploy.yml
Created November 3, 2016 23:10
An example Deployment
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test
spec:
replicas: 1
template:
spec:
containers:
@thomastaylor312
thomastaylor312 / jenkins.yml
Last active November 4, 2016 18:42
Example Ansible role file for populating Kubernetes YAML files
- include_vars: "group_vars/secrets/secrets_{{ k8s_environment }}_{{ jenkins_type }}.yml"
- name: "Jenkins specs directory"
file:
dest: "./build/{{ k8s_environment }}/"
state: directory
- name: "Jenkins environment directory"
file:
dest: "./build/{{ k8s_environment }}/jenkins"
state: directory
- name: "Set path where specs go"
@thomastaylor312
thomastaylor312 / cassandra.tick
Created November 4, 2016 18:58
An example Kapacitor alert
stream
// The following stream alerts based on changes in cpu/usage
// Every minute the rate of change for the cpu/usage is calculated
// Alerts are sent out when that rate is unusually high
|from()
.measurement('cpu/usage')
.where(lambda: "type" == 'node' AND "nodename" =~/.*cassandra.*/)
.groupBy('nodename')
|derivative('value')
.unit(60s)
@thomastaylor312
thomastaylor312 / check-pods.py
Created November 4, 2016 21:43
Function for checking status of containers in pods
def check_pods(get_pods_json):
problemPods = list()
for pod in get_pods_json['items']:
isBad = False
if pod['status']['phase'] != 'Running' and pod['status']['phase'] != 'Completed':
isBad = True
else:
for container_status in pod['status']['containerStatuses']:
if not container_status['ready']:
isBad = True