Skip to content

Instantly share code, notes, and snippets.

View chrisboulton's full-sized avatar

Chris Boulton chrisboulton

View GitHub Profile
@jessereynolds
jessereynolds / 0-puppet-node-purging-via-api.md
Last active March 21, 2022 09:42
Puppet - Node Purging via APIs

Puppet Node Purging via API

When you're decomissioning a machine that has been managed by Puppet you may want to programatically clean up the node. There are two parts to this:

  • revoking and deleting the certificate of the node in Puppet's CA
  • deactivating the node in PuppetDB

The following should work for Puppet 4.x and Puppet DB 4.x (including Puppet Enterprise 2016.4.x, 2017.1.x, 2017.2.x).

I've used certificate based auth, and the examples are being run from the puppet master so make use of existing certificates for authentication. When run remotely the cacert, certificate and corresponding private key for authentication will need to be present.

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@Fornoth
Fornoth / Notes.md
Last active September 27, 2023 17:52
Makes a device show up in spotify connect devices list, but nothing else yet

#Python Script Setup

To get the python script running, run either pip install flask or pip install -r requirements.txt if you used git clone to clone the gist

#libspotify_embedded_shared.so notes

##Using the library (still in progress) There's a compile.sh that compiles a program that calls SpInit(), but doesn't get any farther because it needs more than just the API version number (which is 4)

##Spotify appkey

@DavidWittman
DavidWittman / supermicro-psblock-fix.expect
Last active January 27, 2022 20:02
This expect script secures SuperMicro IPMI implementations which are vulnerable to viewing the IPMI password in plaintext on port 49152.
#!/usr/bin/expect -f
# This script secures SuperMicro IPMI implementations which are vulnerable
# to viewing the IPMI password in plaintext on port 49152. It does this by
# using the shell available in some SuperMicro BMCs to drop traffic to port
# 49152 in iptables.
#
# See http://blog.cari.net/carisirt-yet-another-bmc-vulnerability-and-some-added-extras/
# for more details on the vulnerability.
#
@bf4
bf4 / Gemfile
Created July 2, 2013 18:36
Rails lograge and logstash request logging
gem 'lograge' # more readable logs
gem 'logstash-event' # for logstash json format
gem 'mono_logger' # threadsafe logging
@rodjek
rodjek / 0_description.md
Last active December 19, 2015 03:18
check_puppet_run_health

check_puppet_run_health

A Nagios check that connects to PuppetDB and determines the Puppet agent run health on a host.

Requires

  • PuppetDB
  • A puppetmaster configured to send reports to PuppetDB

States

@rockymadden
rockymadden / processing-chassis-3u-8node.md
Last active December 17, 2015 05:58
One simple example of a 10u/13node hardware private cloud infrastructure. Built specifically for colocation, based on how datacenters often slice up their racks (e.g. 10u/quarter rack is very common). Saves a few hundred thousand dollars over AWS in three years time. Replace/repeat at that time and then put these into a Hadoop cluster or somethi…

This chassis houses up to 8 processing nodes. Each node is roughly equivilent to 30 elastic compute units. You can scale as needed by building and slotting more nodes into the chassis. Candidates for these nodes includes: app servers of any kind, ssl termination/reverse proxies, cache servers, distributed/concurrent processing, cron jobs, etc.

Barebone:


Per node (up to 8):

@mrflip
mrflip / 20130416-todo.md
Last active January 21, 2024 21:06
Elasticsearch Tuning Plan

Next Steps

  • Measure time spend on index, flush, refresh, merge, query, etc. (TD - done)
  • Take hot threads snapshots under read+write, read-only, write-only (TD - done)
  • Adjust refresh time to 10s (from 1s) and see how load changes (TD)
  • Measure time of a rolling restart doing disable_flush and disable_recovery (TD)
  • Specify routing on query -- make it choose same node for each shard each time (MD)
  • GC new generation size (TD)
  • Warmers
  • measure before/after of client query time with and without warmers (MD)
@wofeiwo
wofeiwo / fcgiclient.go
Created September 15, 2012 09:08
Golang FastCGI Client
// Copyright 2012 Junqing Tan <ivan@mysqlab.net> and The Go Authors
// Use of this source code is governed by a BSD-style
// Part of source code is from Go fcgi package
// Fix bug: Can't recive more than 1 record untill FCGI_END_REQUEST 2012-09-15
// By: wofeiwo
package fcgiclient
import (