Skip to content

Instantly share code, notes, and snippets.

@rhowardiv
rhowardiv / dd-log-export.bash
Created August 5, 2019 13:32
Datadog log export -- approach not viable due to rate limit (300 reqs/h)
#!/bin/bash
set -e
if [[ -z "$DD_APP_KEY" ]]; then
echo "I expect the Datadog app key in DD_APP_KEY"
exit
fi
if [[ -z "$DD_API_KEY" ]]; then
echo "I expect the Datadog API key in DD_API_KEY"
exit
@rhowardiv
rhowardiv / pyfunclen.py
Last active October 28, 2016 18:09
Count lines in python functions
#!/usr/bin/env python
"""
Count lines in python functions
"""
import re
def funcs_lengths(lines):
"""
Loop through lines and yield (function name, line length)
@rhowardiv
rhowardiv / Makefile
Last active August 29, 2015 14:17
generic Makefile for markdown work
export SHELL := /bin/bash
.PHONY: default pdf html view clean
SRC = $(wildcard *.txt)
PDFS=$(SRC:.txt=.pdf)
HTML=$(SRC:.txt=.html)
default: pdf html
pdf: $(PDFS)
%.pdf : %.txt
@rhowardiv
rhowardiv / jake
Created October 21, 2014 13:04
Jake: run make and get a notification with the results from Jake the Dog (you provide jake.png...)
#!/bin/bash
[ -t 1 ]
ISTTY=$?
notify-send -i ~/Pictures/jake.png MAKE "$( (make $@ && echo "Good.") 2>&1 | ( if [[ $ISTTY -eq 0 ]]; then tee /dev/tty; else cat; fi ) )"
@rhowardiv
rhowardiv / Httpd Requests
Last active August 29, 2015 14:06
snap-kibana
{
"title": "Httpd Requests",
"services": {
"query": {
"list": {
"0": {
"id": 0,
"type": "topN",
"query": "*",
"alias": "",
@rhowardiv
rhowardiv / gist:7142092
Last active December 26, 2015 11:09
Add length sorting to selecta inputs
$ git diff HEAD^
diff --git a/vimrc b/vimrc
index cada33f..18f0b56 100644
--- a/vimrc
+++ b/vimrc
@@ -275,15 +275,15 @@ endfunction
" Find all files in all non-dot directories starting in the working directory.
" Fuzzy select one of those. Open the selected file with :e.
-nnoremap <leader>f :call SelectaCommand("find * -type f \| lsort", "", ":e")<cr>
@rhowardiv
rhowardiv / gist:4197652
Created December 3, 2012 20:11
PHP magic __get only allows itself on the stack once per property
<?php
class Dumb {
protected $prop;
function __get($p) {
if ($p === 'prop') {
$this->prop = new Dumber($this);
return $this->prop;
}
}
}
@rhowardiv
rhowardiv / rpr.sh
Last active October 11, 2015 20:08
Get a random PR checker
#!/bin/bash
# Get a random PR checker
# Loops through everyone before showing the same name twice
ME=rhoward
# Takes optional argument for commit group if you want not from "ALL"
COMMIT_GROUP="ALL"
if [ $# -gt 0 ]; then
COMMIT_GROUP="$1"
@rhowardiv
rhowardiv / ppt.sh
Created October 9, 2012 19:23
powerpoint in bash
#!/bin/bash
usage() {
echo "Interactively show slides from a file"
echo
echo "Usage:"
echo "$0 FILE LINES"
echo
echo "FILE is the file containing the slides."
echo "In the file, each slide is indicated with a simple 'slide' by itself"
@rhowardiv
rhowardiv / syncdaemon
Created September 7, 2012 20:04
remote file sync for Mac
#!/bin/bash
LOG=/tmp/sync.log
SELF=$(basename "$0")
usage() {
echo
echo "Usage: $SELF LOCALDIR REMOTEDIR"
echo "Syncs files in LOCALDIR to REMOTEDIR"
echo "Daemonize this yourself with & or nohup"