Skip to content

Instantly share code, notes, and snippets.

@rhowardiv
rhowardiv / dd-log-export.bash
Created Aug 5, 2019
Datadog log export -- approach not viable due to rate limit (300 reqs/h)
View dd-log-export.bash
#!/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 Oct 28, 2016
Count lines in python functions
View pyfunclen.py
#!/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 Aug 29, 2015
generic Makefile for markdown work
View Makefile
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 Oct 21, 2014
Jake: run make and get a notification with the results from Jake the Dog (you provide jake.png...)
View jake
#!/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 ) )"
View Httpd Requests
{
"title": "Httpd Requests",
"services": {
"query": {
"list": {
"0": {
"id": 0,
"type": "topN",
"query": "*",
"alias": "",
@rhowardiv
rhowardiv / gist:7142092
Last active Dec 26, 2015
Add length sorting to selecta inputs
View gist:7142092
$ 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 Dec 3, 2012
PHP magic __get only allows itself on the stack once per property
View gist:4197652
<?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 Oct 11, 2015
Get a random PR checker
View rpr.sh
#!/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 Oct 9, 2012
powerpoint in bash
View ppt.sh
#!/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 Sep 7, 2012
remote file sync for Mac
View syncdaemon
#!/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"