Skip to content

Instantly share code, notes, and snippets.

@dstrbad
dstrbad / macOS Internals.md
Created May 7, 2023 10:51 — forked from kconner/macOS Internals.md
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

#!/bin/bash
IP="192.168.1.22"
SUBJECT_CA="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=CA/CN=$IP"
SUBJECT_SERVER="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Server/CN=$IP"
SUBJECT_CLIENT="/C=SE/ST=Stockholm/L=Stockholm/O=himinds/OU=Client/CN=$IP"
function generate_CA () {
echo "$SUBJECT_CA"
openssl req -x509 -nodes -sha256 -newkey rsa:2048 -subj "$SUBJECT_CA" -days 365 -keyout ca.key -out ca.crt
@dstrbad
dstrbad / install-configure-letsencrypt.sh
Created June 12, 2021 10:03 — forked from craigvantonder/install-configure-letsencrypt.md
Install and configure LetsEncrypt on Ubuntu Server 14.04 & 16.04 (Apache)
#!/bin/bash
# https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-14-04
# Download the Let’s Encrypt Client
cd /usr/local/sbin
sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x /usr/local/sbin/certbot-auto
# Set Up the SSL Certificate
@dstrbad
dstrbad / tmux-cheatsheet.markdown
Created November 28, 2017 16:37 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@dstrbad
dstrbad / jenkins-go.sh
Created November 28, 2016 15:37 — forked from marinbek/jenkins-go.sh
jenkins golang setup
export GOROOT=/usr/local/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH:$WORKSPACE/bin
export GOPATH=$WORKSPACE
git config url."git@github.com:".insteadOf "https://github.com/"
go get github.com/AlekSi/gocov-xml
go get github.com/axw/gocov/gocov
mkdir -p $GOPATH/src/github.com/NextUserSF/
from tastypie import fields
from tastypie.authentication import Authentication
from tastypie.authorization import Authorization
from tastypie.bundle import Bundle
from tastypie.exceptions import NotFound
from tastypie.resources import Resource
# a dummy class representing a row of data
class Row(object):

Application specific host grouping in Riemann-dash

It is generally desirable to group all the hosts for a specific service into a single dashboard view. For example, all the web servers are in single view while all the database servers are in another view.

This is usually not an issue when you are sending custom metrics using Riemann client. However, there are cases where you are using something that you do not control how the metrics are being sent. i.e., Riemann-tools.

Since Riemann-tools scripts are application agnostic, in order for the dashboard view to group hosts, we must inject some application specific information into the tags field. Tags is a collection of arbitrary strings. In the case of Riemann-tools scripts you can pass in arbitrary strings on the command line.

riemann-health --host 127.0.0.1 --tag "prod" --tag "webserver"

SELECT 'drop table '||n.nspname ||'.'|| c.relname||' CASCADE;' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
AND n.nspname = 'destination_schema';
SELECT 'create table '||n.nspname ||'.'|| c.relname||' as select * from source_schema.' || c.relname||';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
SELECT 'UNLOAD (\'select * from '||n.nspname ||'.'|| c.relname||'\') TO \'s3://bucket/' || c.relname || '_\';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind IN ('r','v','S','')
AND n.nspname LIKE 'nu_alibris';
SELECT 'COPY ' || n.nspname ||'.'|| c.relname ||' from \'s3://bucket/' || c.relname || '_\';' as "Name"
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
#!/usr/bin/env python
import sys, os, time, atexit
from signal import SIGTERM
class Daemon:
"""
A generic daemon class.
Usage: subclass the Daemon class and override the run() method