Skip to content

Instantly share code, notes, and snippets.

@jewzaam
jewzaam / gist:2de9c1bb79758d5bb010
Last active August 29, 2015 14:10
MongoDB shard in docker
# setup:
# - one config server
# - one mongos server
# - 3 shard nodes (single mongod)
# reference: https://gist.github.com/achille/82847acc0b4b94ca9f0f
# start config server (note, override default db path to one already managed by mongo image)
docker run --name mongo-shard-config -d mongo --nojournal --oplogSize 10 --configsvr --dbpath /data/db
@jewzaam
jewzaam / gist:d6a81e35062ba0718454
Last active August 29, 2015 14:10
MongoDB single node in docker
# server
docker run --name mongo-single -d mongo --nojournal --oplogSize 10
# client
docker run -it --link mongo-single:mongo --rm mongo /bin/bash
mongo mongo:27017
@jewzaam
jewzaam / gist:6b6ac2a66fd73971b5ab
Last active August 29, 2015 14:11
deploy openshift-lightblue-cart via REST API
# setup
OS_USERNAME=<user>
OS_PASSWORD=<password>
OS_GEAR_SIZE="medium"
# verify you can get application list
curl -k -X GET https://openshift.redhat.com/broker/rest/domain/lightblue/applications --user $OS_USERNAME:$OS_PASSWORD
# delete existing app, get ID from app list above
curl -k -X DELETE https://openshift.redhat.com/broker/rest/application/<ID> --user $OS_USERNAME:$OS_PASSWORD
@jewzaam
jewzaam / gist:a9a3a3d585a97688d5e9
Created January 5, 2015 18:48
Example JSON Schema for lightblue metadata: country/1.0.0
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "JSON schema for entity 'country' version '1.0.0' (see https://raw.githubusercontent.com/lightblue-platform/openshift-lightblue-cart/master/versions/shared/template/src/main/data/country.json)",
"properties": {
"createdBy": {
"type": "string",
"description": "Identifies who created this entity. Ideally, a login. Worst case an ID from some other system."
},
"creationDate": {
sed 's/\([ ]*\)\([^ :]*\)[ ]*:[ ]*\([^,]*\).*/\1"\2": "\3",/g' | sed 's/"{",/{/g' | sed 's/"\[",/[/g' | sed 's/""/"/g'
@jewzaam
jewzaam / README.md
Last active April 25, 2016 15:00 — forked from Ulrhol/README.md

##Yet another gist to provide Graphite support for Dashing Pull data from Graphite and present in Dashing. Support both graph and number widget.

Quick install:

dashing install efffa657c31e244131e3

Set the graphite name and names of metrics in jobs/graphite.rb

@jewzaam
jewzaam / find.json
Last active November 29, 2016 15:49
Self reference on array contents. Note the reference in the metadata may be wrong. This doesn't work yet, so the exact query hasn't been worked out yet.
{
"objectType": "selfReferenceArrayContainsArray",
"projection": [
{
"field": "*",
"include": true,
"recursive": true
},{
"field": "test_reference",
"include": true,
@jewzaam
jewzaam / OctoPrint-MultiColors Configuration.md
Last active April 8, 2018 00:25
OctoPrint-MultiColors Configuration

https://github.com/MoonshineSG/OctoPrint-MultiColors

I slice with Slic3r and have enabled verbose GCODE. I found GOCDE to move the hot end off the print at a layer change (reference eludes me right now). Wanted to share what I did with this OctoPrint plugin for my setup.

The trick is to get the retract, extrucsion reset, and Z change captured in a group so you can replay it.

My regex: (.*layer [(]{0}[)])\n(G1 X.*move.*)\n(G1 E([\d.]*) F([\d.]*)[; ]*.*unretract)

My GCODE:

@jewzaam
jewzaam / README.md
Last active September 7, 2018 18:33
API Key Authentication for Open REST API

Sometimes you need simple authentication in front of a REST endpoint that doesn't provide authentication. In this gist I outline how to do this with API Gateway and Lambda.

The original goal with this work was to secure a deployment of Prometheus node_exporter. I have since found the configuration for the prometheus-operator does not support setting custom headers, only Authorization. See https://prometheus.io/docs/prometheus/latest/configuration/configuration/#%3Cscrape_config%3E

What was done:

. Create EC2 instance (sg allows 9100) . Install node_exporter on :9100 . Create Lambda function . Create API Gateway

@jewzaam
jewzaam / _Prometheus scrape external endpoints.md
Last active October 11, 2018 02:41
Setup Prometheus to scrape external node-exporter

Setup Prometheus to scrape external node-exporter

This came out of an ansible role I was creating to monitor some external hosts that run node-exporter. I've since moved away from exposting node-exporter and am using prometheus pushgateway instead. This gist exists to capture what I learned.

How does it work?

Deploy the endpoint, service, and servicemonitor in the openshift-monitoring namespace. You should be able to deploy to another project but you'll maybe have problems with reading data. A couple of notes on that at the end

Ansible snippet to make this happen (I have not tested this). Assumes the host it runs on has ability to run oc commands against openshift-monitoring.