Skip to content

Instantly share code, notes, and snippets.

View myoung34's full-sized avatar

myoung34 myoung34

View GitHub Profile
@fpletz
fpletz / esphome-print-async.py
Last active February 23, 2024 00:47
aioesphomeapi minimal examples
#!/usr/bin/env python3
import aioesphomeapi
import asyncio
async def main():
loop = asyncio.get_running_loop()
cli = aioesphomeapi.APIClient(loop, "foobarhostname", 6053, "foobarpassword")
await cli.connect(login=True)
@BRMatt
BRMatt / tf-multitaint
Last active August 6, 2018 11:28
A small utility for tainting a bunch of terraform resources in one go `terraform state list | grep launch_configuration | tf-multitaint`
#!/usr/bin/env ruby
resources = $stdin.readlines.map(&:split).flatten.map do |resource|
{
module: resource.scan(%r{module\.([a-z0-9\-_]+)}).to_a.join("."),
identifier: resource.match(%r{(?:module\.[a-z0-9\-_]+\.)*(.*)$}).captures.first,
}
end
resources.each do |resource|
class CustomTask(Task):
def on_failure(self, exc, task_id, args, kwargs, einfo):
info = '[{0}] failed: {1}'.format(task_id, exc)
logger.exception(info, exc_info=exc)
super(CustomTask, self).on_failure(exc, task_id, args, kwargs, einfo)
def on_success(self, retval, task_id, args, kwargs):
global app
if app.is_warm_shutdown:
app.consumer.connection._default_channel.do_restore = False
@cheeseplus
cheeseplus / bootstrapping.md
Created February 16, 2018 18:05
chef bootstrapping

One of the earliest lessons in a users' journey with using Chef is how to bootstrap a node with knife. Most of the tutorials will very reasonably illustrate some form of knife bootstrap but the immediate follow on question is often, how do I do this in production? The answer to that question is less directly clear because different infrastructure needs will lend themselves to different approaches. With the following I want to break down "bootstrapping" and illustrate a few approaches. This is not meant to be a comprehensive review of evertyhing possible but a deconstruction of the primitives in play.

a brief detour regarding validation

Since Chef 12.2.0, the default bootstrapping method is "validatorless" - which as the name implies, exists in opposition to the fomer "validator" based approach. The older approach makes use of the unique org "validator" key that is created as part of an organisation on chef-server, you may have seen it referenced as "validation.pem" or "org-validator", which allows an

@Faheetah
Faheetah / Jenkinsfile.groovy
Last active June 17, 2024 15:05
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"
@rlouapre
rlouapre / Dockerfile
Last active August 29, 2015 14:07
Dockerfile for ML7
FROM centos:centos6
MAINTAINER Richard Louapre <richard.louapre@marklogic.com>
#update yum repository and install openssh server
RUN yum update -y
RUN yum install -y openssh-server
#generate ssh key
RUN ssh-keygen -q -N "" -t dsa -f /etc/ssh/ssh_host_dsa_key
RUN ssh-keygen -q -N "" -t rsa -f /etc/ssh/ssh_host_rsa_key
@karmi
karmi / hbase-rest-examples.sh
Created September 15, 2011 09:53
Experiments with the HBase REST API
#!/usr/bin/env bash
#
# ===================================
# Experiments with the HBase REST API
# ===================================
#
# <http://hbase.apache.org/docs/r0.20.4/api/org/apache/hadoop/hbase/rest/package-summary.html>
#
# Usage:
#