Skip to content

Instantly share code, notes, and snippets.

using System;
using Nancy;
using Nancy.Hosting.Self;
namespace HelloNancy
{
public class HelloNancy : NancyModule
{
public HelloNancy ()
{
@clofresh
clofresh / README.md
Last active December 30, 2015 20:49
Hack to enable dogstatsd debug logging

We don't have debug logging in dogstatsd as it can potentially receive a huge amount of data and logging the incoming udp packets will kill cpu/disk. Sometimes we need to see that data though when trying to debug dogstatsd submission, so here is a hacky way to do it.

To apply it:

cd /
curl https://gist.github.com/clofresh/7883109/raw/75718cf42179d2199643daeea47fcec387e42281/dogstatsd_debug.py.patch | sudo patch -p 0
sudo service datadog-agent restart
import requests
import simplejson
url = 'http://blah'
response = requests.get(url)
data = response.json()
@clofresh
clofresh / main.lua
Created June 1, 2013 22:03
Dragon curves. Wikipedia reference: https://en.wikipedia.org/wiki/Dragon_curve
local curves = {}
local timer = 0
local iterations = 0
function newCurve(startX, startY, startDir, lineLen, color)
return {
startX = startX,
startY = startY,
startDir = startDir,
lineLen = lineLen,
@clofresh
clofresh / datadog.conf
Last active March 3, 2023 22:24
Multiline datadog agent log parser
[Main]
dogstreams: /path/to/log:/path/to/multiline.py:MultilineParser
try:
import simplejson as json
print json, json.__version__
except ImportError:
try:
import json
print json, json.__version__
except ImportError:
import minjson
class json(object):
diff --git a/lib/py/setup.py b/lib/py/setup.py
index d111bb1..5a0b59c 100644
--- a/lib/py/setup.py
+++ b/lib/py/setup.py
@@ -19,14 +19,14 @@
# under the License.
#
-from distutils.core import setup, Extension
+from setuptools import setup, Extension
$ python test_mcache.py
no monkeypatch
Start mem: 7491584 End mem: 41394176 Difference 33902592
$ python test_mcache.py monkeypatch
monkeypatch
Start mem: 7491584 End mem: 7491584 Difference 0
# Make the eventual new master a slave of the old master
knife node run_list add $NEW_MASTER 'role[redis-slave]'
ssh $NEW_MASTER sudo chef-client
# Wait a bit for the slave to catch up
sleep 30
# Designate the slave as the new master and remove the master status from the
# old master. This only updates chef metadata, the changes won't take place
# until a chef-client is run.
@clofresh
clofresh / gist:1298904
Created October 19, 2011 16:50
Sample metrics objects
metrics = MetricFamily('my_app')
results = do_work()
metrics.record('result.created', len(results)) # my_app.result.created
for result in results:
result.save()
# my_app.result.saved. Each time increment is called, either increment the value at that timestamp (truncated
# to the second) or create a new point and increment that value.
metrics.increment('result.saved')