Skip to content

Instantly share code, notes, and snippets.

@mrtazz
mrtazz / client.rb
Created September 4, 2012 04:05
send chef-client output to syslog
require 'rubygems'
require 'syslog-logger'
log_level :info
Logger::Syslog.class_eval do
attr_accessor :sync, :formatter
end
log_location Logger::Syslog.new("chef-client")
@jcjones
jcjones / letsencrypt-renew.sh
Last active October 11, 2016 16:29
Cron script to renew Let's Encrypt certs using the official client
#!/bin/bash
# This is free and unencumbered software released into the public domain.
#
# This script is designed to be run daily by cron. Please run it with randomness in its timing to
# avoid load spikes at Let's Encrypt. One example, running between midnight at 2 AM, would be:
#
# 0 0 * * * sleep $[(RANDOM % 115)+5]m ; /usr/sbin/letsencrypt-renew.sh
#
# If you aren't using Nginx, adjust the startServer and stopServer methods to suit. Also, you could
# use the webroot method.
@mislav
mislav / example.rb
Created March 12, 2012 18:59
Dump objects into YAML using specific style
full_data = {
response: {body: StyledYAML.literal(DATA.read), status: 200},
person: StyledYAML.inline('name' => 'Steve', 'age' => 24),
array: StyledYAML.inline(%w[ apples bananas oranges ])
}
StyledYAML.dump full_data, $stdout
__END__
{
@renzok
renzok / bash-template
Last active July 29, 2023 12:31
A template bash script based on google style guide with some little improvements
#!/bin/bash
# Here short description of this script
# This is just a template to be used for writing new bash scripts
###
# Based on Google Style Guide: https://google.github.io/styleguide/shell.xml
# General remarks
# * Executables should have no extension (strongly preferred) or a .sh extension.
# * Libraries must have a .sh extension and should not be executable
@miketheman
miketheman / zook_grow.md
Created July 22, 2013 21:36
Adding nodes to a ZooKeeper ensemble

Adding 2 nodes to an existing 3-node ZooKeeper ensemble without losing the Quorum

Since many deployments may start out with 3 nodes and so little is known about how to grow a cluster from 3 memebrs to 5 members without losing the existing Quorum, here is an example of how this might be achieved.

In this example, all 5 nodes will be running on the same Vagrant host for the purpose of illustration, running on distinct configurations (ports and data directories) without the actual load of clients.

YMMV. Caveat usufructuarius.

Step 1: Have a healthy 3-node ensemble

@khalidx
khalidx / bash-reusable.md
Created October 2, 2023 22:12
Reusable bash functions.

Include the code below in any bash script!

This is a good way to start a bash script:

#!/usr/bin/env bash
set -eou pipefail

These are some useful generic reusable bash functions.

@miry
miry / Gemfile
Last active January 27, 2024 07:37
Sidekiq gracefull startup and shutdown in Kubernetes
# frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
gem "sidekiq"
@foriequal0
foriequal0 / StableNameStack.ts
Last active March 7, 2024 05:05
CDK StableNameStack
import { CfnElement, CfnResource, Stack } from "@aws-cdk/core";
import { makeUniqueId } from "@aws-cdk/core/lib/private/uniqueid";
import { Node } from "constructs";
import * as assert from "assert";
const PINNED_RESOURCE_NAMES_CONTEXT_KEY = "pinnedLogicalIds";
type PinnedLogicalIds = { [segment: string]: PinnedLogicalIds | string };
export class StableNameStack extends Stack {
@magnetikonline
magnetikonline / README.md
Last active April 30, 2024 00:45
Setting Nginx FastCGI response buffer sizes.
@clintel
clintel / gist:1155906
Created August 19, 2011 02:40
Fenced code in bullet lists with GitHub-flavoured MarkDown??

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code