Skip to content

Instantly share code, notes, and snippets.

import subprocess
def shell(*args, **kwargs):
"""Execute a shell command and return the output as a string.
Any additional kwargs are passed directly to subprocess.run.
Examples:
shell("date")
shell("date", "-u")
message = "hello, world"
shell("echo", message)
securityDefinitions:
api_key:
in: query
name: key
type: apiKey
api_token:
in: query
name: token
type: apiKey
#!/usr/bin/env ruby
require 'digest'
module VanitySha
extend self
COMMITTER_PATTERN = /^committer .* \<.*\> (?<timestamp>\d+)(?<timezone>.*$)/
AUTHOR_PATTERN = /^author .* \<.*\> (?<timestamp>\d+)(?<timezone>.*$)/
TIMESTAMP_DELTA_MAX = 10 * 24 * 60 * 60
CREATE TABLE metrics (
id bytea NOT NULL primary key,
description text,
name text COLLATE pg_catalog."C"
);
CREATE TABLE contribution_metrics (
last_update_on timestamp with time zone,
metric bytea NOT NULL,
projected double precision,
psql> explain analyze select investments.id
from contributions
JOIN investments ON contributions.investment_id = investments.id
JOIN contribution_investment_metrics cim on cim.investment_id = investments.id
WHERE contributions.id = '\x58c9c0d3ee944c48b32f814d';
QUERY PLAN
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Nested Loop (cost=27098.32..27106.89 rows=1 width=13) (actual time=1322.324..1322.329 rows=1 loops=1)
Join Filter: (contributions.investment_id = investments.id)
-> Merge Join (cost=27098.
import gdb
from datetime import datetime
import sys
if sys.version_info > (3, 0):
raw_input = input
#
# The gdb constant COMPLETE_EXPRESSION was added in gdb 7.7. For earlier
# version of gdb, we use COMPLETE_SYMBOL which is close enough.
#pragma once
// A parent class using CRTP to track all instances of the derived class.
//
// This supports two python functions for use in gdb:
//
// - TrackedClassWalk(derived_class_name, filter=lambda _: True):
//
// A generator that iterates over all instances of the derived class
// in existance. This currently relies on embedding additional data in
#!/usr/bin/python
# -*- coding: utf-8 -*-
import argparse
import blessed
from collections import defaultdict
import csv
import jinja2
import logging
import numpy
Date/Time: 2015-11-11 16:48:02 -0800
OS Version: 10.10.5 (Build 14F1021)
Architecture: x86_64
Report Version: 21
Event: Sleep Wake Failure
Steps: 8
Hardware model: MacBookPro10,1
Active cpus: 8
@awreece
awreece / perf_post_process.sh
Last active August 29, 2015 14:27
[WORK IN PROGRESS] automatically generate latency graphs
#!/bin/bash
#
# Generates a "latency heat map", showing both on-CPU and off-CPU stacks. In addition,
# attempts to color code on-CPU based on CPI by diffling the on-CPU stacks sampled
# at ~1000 Hz and every ~3e6 instructions. Intuitively, if a stack is more common in
# frequency stacks than in count stacks, than it represents a "slower" stack.
#
perf_data_dir=$1
dest_dir=$2