Skip to content

Instantly share code, notes, and snippets.

@alperkokmen
alperkokmen / pd-event.sh
Last active April 6, 2024 20:39
Simple script to trigger, acknowledge, and resolve incidents via PagerDuty Integration API.
#!/bin/bash
CONTENT_TYPE="application/json"
DESCRIPTION="bad things™ are happening"
URL="https://events.pagerduty.com/generic/2010-04-15/create_event.json"
if [ $# -ne 3 ]; then
echo "Usage: pd-event.sh [TYPE] [SERVICE KEY] [INCIDENT KEY]"
echo " - TYPE: [t]rigger | [a]cknowledge | [r]esolve"
echo " - SERVICE KEY: unique identifier for service"
@earthgecko
earthgecko / bash.generate.random.alphanumeric.string.sh
Last active April 2, 2024 15:59
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1
@Faheetah
Faheetah / Jenkinsfile.groovy
Last active March 6, 2024 18:14
Jenkinsfile idiosynchrasies with escaping and quotes
node {
echo 'Results included as an inline comment exactly how they are returned as of Jenkins 2.121, with $BUILD_NUMBER = 1'
echo 'No quotes, pipeline command in single quotes'
sh 'echo $BUILD_NUMBER' // 1
echo 'Double quotes are silently dropped'
sh 'echo "$BUILD_NUMBER"' // 1
echo 'Even escaped with a single backslash they are dropped'
sh 'echo \"$BUILD_NUMBER\"' // 1
echo 'Using two backslashes, the quotes are preserved'
sh 'echo \\"$BUILD_NUMBER\\"' // "1"
@cgoldberg
cgoldberg / merge_junit_results.py
Last active January 10, 2024 19:19
Merge multiple JUnit XML results files into a single results file.
#!/usr/bin/env python
"""Merge multiple JUnit XML results files into a single results file."""
# MIT License
#
# Copyright (c) 2012 Corey Goldberg
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@k0emt
k0emt / DarkMatterLogger.py
Created September 15, 2011 04:00
Demo code for RabbitMQ Publish/Subscribe (fanout) exchange with Python
import sys
import pika
# prerequisites are that you have RabbitMQ installed
# create a "darkmatter" named VirtualHost (VHOST)
# rabbitmqctl.bat add_vhost darkmatter
# create a user APP_USER with associated APP_PASS word
# rabbitmqctl add_user darkmatteradmin <password>
# give the APP_USER the necessary permissions
# rabbitmqctl set_permissions -p darkmatter darkmatteradmin ".*" ".*" ".*"
@actionjack
actionjack / killAllBuilds.groovy
Created March 16, 2022 15:38 — forked from brandonfl/killAllBuilds.groovy
Kill all build and remove queued ones
import java.util.ArrayList;
import hudson.model.*;
def q = Jenkins.instance.queue
for (queued in Jenkins.instance.queue.items) {
q.cancel(queued.task)
}
for (job in Jenkins.instance.items) {
stopJobs(job)
@phrawzty
phrawzty / S3_as_Yum_repo.md
Last active November 10, 2023 19:20
Use S3 as a Yum repo

S3 as Yum repo

There are two parts to this:

  • Managing access to non-public S3 resources.
  • Building RPM repositories in an automated, deterministic way that Yum can use.

Environment

In general, a CentOS 7 x86_64 box in AWS EC2; in specific, this Packer profile.

@svrist
svrist / cf_create_or_update.py
Created February 7, 2017 21:34
Update or create a CloudFormation stack given a name and template + params'
'Update or create a stack given a name and template + params'
from __future__ import division, print_function, unicode_literals
from datetime import datetime
import logging
import json
import sys
import boto3
import botocore
@rachelmyers
rachelmyers / Chromebook_setup.md
Last active October 25, 2023 10:00
How I set up my Chromebooks' dev environment

Chromebook Setup Options

Option 1: Stay in Chrome OS

If you're writing bare-bones javascript for the browser, creating Chrome Apps and Extensions, or using remote coding apps like cloud9, Koding, or Nitrous, you may not need to install Ubuntu. Some tutorials can be done entirely within the browser. The tradeoff is that you won't have a full-featured command line, and you may hit a point where you can't install something that you need.

To start coding within Chrome OS, install Text or Caret as a text editor. (Text stores files in Google Docs and Caret stores the files locally on your machine, which may help you choose.) After that, you're good to go, since Chromebooks come with a browser installed.

Optio

@sawanoboly
sawanoboly / haproxy.cfg
Created November 15, 2011 10:28
mongos behind haproxy configuration.
global
daemon
user haproxy
group haproxy
log /dev/log daemon info
maxconn 4096
defaults
log global
option dontlognull