Skip to content

Instantly share code, notes, and snippets.

@pcn
pcn / example.md
Last active September 14, 2023 19:40
Using jq to get+filter aws data

I've been playing with jq, and I've been having a hard time finding examples of how it works with output from a service like AWS (which I use a lot).

Here is one I use a lot with vagrant-ec2.

When we're launching and killing a lot of instances, the AWS API is the only way to track down which instances are live, ready, dead, etc.

To find instances that are tagged with e.g. {"Key" = "Name", "Value" = "Web-00'} in the middle of a vagrant dev cycle, or a prod launch/replace cycle, you can do something like this:

@pcn
pcn / ntpq.py
Created December 13, 2016 19:25
A subset of ntqp in python based on ntp python lib
#!/usr/bin/env python
# pragma pylint: disable=bad-whitespace
###############################################################################
# ntpq.py - Python NTP control library.
# Copyright (C) 2016 Peter C. Norton (@pcn on github)
#
# this addition to ntplib is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your option)
@pcn
pcn / util.py
Last active July 29, 2021 18:37
Assoc-in and get-in for python
# XXX maybe move this to the util module
# Let's make our lives easier with assoc-in and get-in
# From: https://stackoverflow.com/questions/10578554/equivalent-of-clojures-assoc-in-and-get-in-in-python
# with additional support for deferencing an array
def _assoc_in(dct, path, value, sep=':'):
"""In a dictionary dct, using the path (which is a
<sep>-separated string) assign the resulting key to value,
overwriting it if its present. If it encounters an iterable and the current
path component is an integer, operates on that.
"""
@pcn
pcn / main.go
Created January 28, 2019 02:32
Further down the skycfg/protobof/envoy rabbit hole
package main
import (
"context"
"fmt"
"reflect"
docopt "github.com/docopt/docopt-go"
"github.com/gogo/protobuf/jsonpb"
@pcn
pcn / gist:d4a9cd1ea42e6e02f5e1
Last active January 13, 2021 15:35 — forked from tbonza2/gist:20757551443a61254aa6
Saltstack mode for emacs

Saltstack mode for emacs

Earlier today I was looking for a Saltstack mode for emacs. Couldn't find one, so I posted the question on Stack overflow. Somebody had a good suggestion about using yaml-mode because a Sublime Text implementation appeared to be taking this approach.Another person thought that Saltstack's use of jinja templates would make an emacs mode easy enough to configure. These were both helpful ideas so I wanted to implement parts of each.

Reasoning

After looking around, I found that someone had configured an emacs mode for a similar situation. They needed to combine HTML and Python to use Mako templates for a project not involving Saltstack. Since Edx uses Mako t

@pcn
pcn / Comparison.adoc
Last active July 29, 2020 18:38
Going to saltstack from chef as a user

About me

I’m an intermediate/advanced chef user. My main usage has been as a client of the services that chef provides, and not operating the server. My comfort zone is that I am very happy to write and hack on fairly complicated chef cookbooks, LWRPs, and chef-solo work, but I don’t work much with the chef server - I’ve opted to use the hosted service in the past, and very much enjoyed the service.

Why Saltstack?

I’m interested in saltstack. When I first started working with chef in 2011, saltstack was very new, so I learned chef, as the more mature option (though it was still fairly new). Now salt is in a fairly mature phase where it seems to be able to handle the same classes of installation and configuration management that I’ve seen chef work with in the past. This impression is backed up by users of Salt who are clearly using it in their day-to-day operations. So I’m trying it out.

References, etc.

@pcn
pcn / twittermute.txt
Created January 29, 2020 15:33 — forked from IanColdwater/twittermute.txt
Here are some terms to mute on Twitter to clean your timeline up a bit.
Mute these words in your settings here: https://twitter.com/settings/muted_keywords
ActivityTweet
generic_activity_highlights
generic_activity_momentsbreaking
RankedOrganicTweet
suggest_activity
suggest_activity_feed
suggest_activity_highlights
suggest_activity_tweet
Why would this:
```
# This could be expanded into another function to allow for
# reconfiguring more of the clickhouse_config_settings if we find we need
# it in the future.
def config_bg_pool_size(size=2):
"""When replacing a clickhouse node, we want to reduce the background
pool size, because at the default of 8, it'll max out the
resources on its peer nodes as it replicates data to itself.
@pcn
pcn / mumblemumble.md
Created July 22, 2019 19:04
Trying to get ES working on ubuntu with openjdk-11
Exception while retrieving instance list from AWS API: Unable to execute HTTP request: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty
@pcn
pcn / foomap_jinja.md
Created July 17, 2019 20:12
not_working_merge_dicts

This doesn't make a lot of sense to me:

{%   set es_config_per_nodetype = { 'default2': 'default2' } %}
{%   set es_config_per_default = { 'default': 'default' } %}


{% set foo = salt['defaults.merge'](es_config_per_defaults, es_config_per_nodetype) %}

invoking that via: