Skip to content

Instantly share code, notes, and snippets.

@kfdm
kfdm / grafana.json
Last active September 4, 2017 12:12
Prometheus Dropping Port
{
"annotations": {
"list": []
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"hideControls": false,
"id": null,
"links": [],
@kfdm
kfdm / PromProxy.md
Created August 18, 2017 03:08
Prometheus Proxy Example

Promgen Code

Here's the above code with some additional comments for explanation

class ProxyQueryRange(PrometheusProxy):
    def get(self, request):
        data = []
        futures = []
        resultType = None
@kfdm
kfdm / notes.md
Created September 28, 2016 07:37
Prometheus Memory Usage Calculation

Keybase proof

I hereby claim:

  • I am kfdm on github.
  • I am kfdm (https://keybase.io/kfdm) on keybase.
  • I have a public key whose fingerprint is C1A7 7DCA 15E6 664A 615E 325D 5735 679A C6FE 5394

To claim this, I am signing this object:

import logging
from gntp.notifier import GrowlNotifier
logging.basicConfig(level=logging.DEBUG) # So you can see the gntp messages
growl = GrowlNotifier(notifications=['test'])
growl.register()
growl.notify('test', 'test', 'test')
# Remove the app from growl
growl.notify('test', 'test', 'test')
@kfdm
kfdm / gist:4519762
Created January 12, 2013 18:25
Watch a git repo and only rebuild if there are changes.
my_repo:
git.latest:
- name: https://github.com/some/repo.git
- rev: develop
- target: /opt/foo
run_make:
cmd.run:
- cwd: /opt/foo
- name: make install
- watch:
@kfdm
kfdm / __init__.py
Created August 29, 2012 16:10
GNTP Hotfix
import re
import hashlib
import time
import StringIO
__version__ = '0.7'
#GNTP/<version> <messagetype> <encryptionAlgorithmID>[:<ivValue>][ <keyHashAlgorithmID>:<keyHash>.<salt>]
GNTP_INFO_LINE = re.compile(
'GNTP/(?P<version>\d+\.\d+) (?P<messagetype>REGISTER|NOTIFY|SUBSCRIBE|\-OK|\-ERROR)' +
@kfdm
kfdm / clickback.py
Created January 12, 2012 02:26
Sample GNTP notification for feature request
import socket
REGISTER = """GNTP/1.0 REGISTER NONE
Application-Name: Testing
Notifications-Count: 1
Notification-Enabled: True
Notification-Name: Testing
"""
@kfdm
kfdm / gist:1219357
Created September 15, 2011 14:21
Quickly close open programs
-- Taken from http://stackoverflow.com/questions/495323/quit-all-applications-using-applescript/495346#495346
tell application "System Events" to set the visible of every process to true
set white_list to {"Finder", "Adium", "iTunes", "Transmission", "HardwareGrowler", "AppleScript Editor"}
tell application "Finder"
set process_list to the name of every process whose visible is true
end tell
repeat with i from 1 to (number of items in process_list)
@kfdm
kfdm / build-irssi-python.sh
Created July 31, 2010 05:47
Compiling irssi-python
#!/bin/bash
# From http://sector-5.net/archives/irssi-python-for-irssi-0-8-15/
cd irssi-python &&
svn revert -R . &&
patch -p0 -i ../irssi-python-for-0.8.14.patch
sed -i 's/ docs//' Makefile.am &&
sed -i 's|docs/Makefile||' 'configure.in' &&
sed -i 's/pyconstants.c/pycore.c/' 'configure.in' &&
cp /usr/share/autoconf-archive/ac_python_devel.m4 . &&
libtoolize -f -c &&